Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add currying friendly hooks #349

Closed
wants to merge 36 commits into from
Closed

Add currying friendly hooks #349

wants to merge 36 commits into from

Conversation

bordoley
Copy link

@bordoley bordoley commented Mar 11, 2019

I've used these wrappers for useMemo and useEffect fairly extensively and find that they greatly improve the code quality of my components by allowing me to lift callback functions out of the render function. Hence I wanted to propose them for inclusion in reason-react proper. A common way of writing components that use these callback is as follows:

[@react.component]
let make = {
  let createOnClick = (prop1, prop2, ev) => {
    // use the event and props to do perform some side effect
    ()
  };

  (~prop1, ~prop2) => {
    let onClick = ReactHooks.useMemo2(createOnClick, prop1, prop2);
    <button onClick>{React.string("hello world")}</button>;
};

rickyvetter and others added 30 commits February 7, 2019 14:05
* useUrl hook for router

* useLayoutEffect0
Extract router and useRecordApi into separate modules.
@chenglou
Copy link
Member

Hey Dave. We're gonna hold this off. Hooks not released yet

@chenglou
Copy link
Member

chenglou commented Nov 6, 2019

Humm this is a bit too stale, so I'll close it, sorry. Additionally we explicitly don't wanna make the hooks currying-friendly. It has a non-trivial perf cost, plus code understanding cost. Not to mention whatever future react hooks semantics that might not work with currying.

@chenglou chenglou closed this Nov 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants