Last active
October 27, 2018 16:26
-
-
Save ernestofreyreg/7145e90376cb26212acc610dc82f1ba2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 React from 'react' | |
import ReactDOM from 'react-dom' | |
import useStateManager from './useStateManager' | |
import createUrlLoader from './state' | |
const LogicReuse = () => { | |
const [userState, userActions] = useStateManager( | |
createUrlLoader('https://api.github.com/users/ernestofreyreg') | |
) | |
return ( | |
<div className='App'> | |
{userState.loading | |
? <div>Loading</div> | |
: <div>{JSON.stringify(userState.data || userState.error)}</div> | |
} | |
<button onClick={userActions.loadData}>Load User</button> | |
</div> | |
) | |
} | |
ReactDOM.render(<LogicReuse />, document.getElementById('root')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment