Skip to content

Instantly share code, notes, and snippets.

@bashidagha
Created February 26, 2022 04:22
Show Gist options
  • Save bashidagha/c090d139bf5f8a9967ed6bc2c3280bc1 to your computer and use it in GitHub Desktop.
Save bashidagha/c090d139bf5f8a9967ed6bc2c3280bc1 to your computer and use it in GitHub Desktop.
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"};
}else if(action.type === "updateMyName"){
return {...state, username : action.payload};
}else {
return state;
}
}
const store =createStore(returnStateReducer);
const App= () => {
return (
<Provider store={store}>
<div>
<Header/>
<h1>Hello World</h1>
</div>
</Provider>
)
}
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment