Skip to content

Instantly share code, notes, and snippets.

@RichieAHB
Last active October 26, 2018 15:09
Show Gist options
  • Save RichieAHB/61fb286d113a59f038ea9c20e66f2146 to your computer and use it in GitHub Desktop.
Save RichieAHB/61fb286d113a59f038ea9c20e66f2146 to your computer and use it in GitHub Desktop.
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