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
function initRedux(reducer, initialState) { | |
const StateContext = React.createContext(null) | |
const DispatchContext = React.createContext(null) | |
function Provider(props) { | |
const [appState, dispatch] = React.useReducer(reducer, initialState) | |
return ( | |
<StateContext.Provider value={appState}> | |
<DispatchContext.Provider value={dispatch}> | |
{props.children} |
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 actions = Object.keys(actionMap).reduce((acc, key) => { | |
const actionCreator = actionMap[key] | |
const fn = (...args) => { | |
const action = actionCreator(...args) | |
dispatch(action) | |
} | |
return { ...acc, [key]: fn } | |
}, {}) |
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
function initRedux(reducer, initialState) { | |
const StateContext = React.createContext(null) | |
const DispatchContext = React.createContext(null) | |
function Provider(props) { | |
const [appState, dispatch] = React.useReducer(reducer, initialState) | |
return ( | |
<StateContext.Provider value={appState}> | |
<DispatchContext.Provider value={dispatch}> | |
{props.children} |
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
class Table extends React.Component { | |
Head = () => { | |
return ( | |
<div className='head'> | |
</div> | |
) | |
} | |
Body = () => { |
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
class Table extends React.Component { | |
render () { | |
return ( | |
<div className='table'> | |
<div className='head'> | |
</div> | |
<div className='body'> | |
{this.props.items.map((item, index) => ( |