Created
February 26, 2022 04:20
-
-
Save bashidagha/849f931353b95a9ad61d0a6c57cc8063 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {useDispatch, useSelector} from 'react-redux' | |
const Header = ()=> { | |
const user = useSelector((state) => state.username); | |
const dispatch = useDispatch(); | |
return ( | |
<div>{user} | |
<input onChange={(e)=> dispatch({type: "updateMyName", payload: e.target.value}) }> | |
</input> | |
<button onClick={()=> dispatch({type: "updateUser"})}>Change User</button> | |
</div> | |
) | |
} | |
export default Header |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment