Last active
October 26, 2018 15:09
-
-
Save RichieAHB/61fb286d113a59f038ea9c20e66f2146 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 { hook, useState, useEffect } from 'react'; | |
import { myMemoize } from './utils/my-memoize'; | |
import CountsAPI from './services/count-api'; | |
const Comp = (props, [counter, setCounter], [name, setName]) => <div />; | |
// hook(...stateful)(...effectful) | |
/* | |
* statefuls are functions that have access to props (and maybe the previous state?), reducers could be here too. What they return could be a variety of things but they allow react internals to pass the the value and updater to the following hooks and component | |
* effectful has access to access to all states and props and can be memoized in userland | |
*/ | |
export default hook(props => useState(0), props => useState("Rich"))( | |
myMemoize((props, counter, name) => { | |
CountAPI.setCountsForName(counter, name); | |
}) | |
)(Comp); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment