import React , {useContext} from 'react'

const UseContext = () = >{
    
    const UseContextCon = React.createContext({})
    const Son = () = >{
        const {name}  = useContext(UseContextCon)
        return (
            <p>I'm the Son component and my name is {name}</p>)}const Child = () = >{
        const {name}  = useContext(UseContextCon)
        return (
            <p>I'm the Child component and my name is {name}</p>)}return (
        <UseContextCon.Provider value={{name:'context'}} >
            <Son />
            <Child/>
        </UseContextCon.Provider>)}export default UseContext
Copy the code