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 {createStore} from 'redux' | |
import {Provider} from 'react-redux' | |
import Header from './Header' | |
const initialState = {username : "Farshid"}; | |
const returnStateReducer = (state= initialState, action) =>{ | |
if(action.type === "updateUser"){ | |
return {...state, username : "Farhad"}; |
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> |
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} | |
<button onClick={()=> dispatch({type: "updateUser"})}>Change User</button> | |
</div> |
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
const App= () => { | |
return <div><h1>Hello World</h1></div> | |
)} | |
export default App; |
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 {createStore} from 'redux' | |
const store =createStore(); | |
const App= () => { | |
return ( | |
<div> | |
<h1>Hello World</h1> | |
</div> | |
) | |
} |
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 {createStore} from 'redux' | |
const initialState = {username : "Farshid"}; | |
const returnStateReducer = (state= initialState) =>{ | |
return state; | |
} | |
const store =createStore(returnStateReducer); | |
const App= () => { | |
return ( | |
<div> |
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 {createStore} from 'redux' | |
import {Provider} from 'react-redux' | |
const initialState = {username : "Farshid"}; | |
const returnStateReducer = (state= initialState) =>{ | |
return state; | |
} | |
const store =createStore(returnStateReducer); | |
const App= () => { | |
return ( |
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
const Header = ()=> { | |
return ( | |
<div> Header </div> | |
)} | |
export default Header |
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 {createStore} from 'redux' | |
import {Provider} from 'react-redux' | |
import Header from './Header' | |
const initialState = {username : "Farshid"}; | |
const returnStateReducer = (state= initialState) =>{ | |
return state; | |
} | |
const store =createStore(returnStateReducer); | |
const App= () => { |
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
const Header = ()=> { | |
const user = useSelector((state) => state.username); | |
return ( | |
<div>{user} </div> | |
) | |
} | |
export default Header |
NewerOlder