synvox / rehook Goto Github PK
View Code? Open in Web Editor NEWMake React Hooks out of your Recompose enhancers
License: MIT License
Make React Hooks out of your Recompose enhancers
License: MIT License
So you may want to update your readme.
following warning is rising when using withState and with withHandlers:
React Hook useMemo has a missing dependency: 'props'. Either include it or remove the dependency array react-hooks/exhaustive-deps
rehook/src/rehook/with-state.js
Line 13 in 5a2164c
why the code does not pass props as dependency?
useMemo(() => initialState(props), [props])
I have optimized withHandlers like this
const withHandlers = handlers => (props: any = {}) => {
const realHandlers = React.useMemo(
() => (typeof handlers === "function" ? handlers(props) : handlers),
[]
)
const [state] = React.useState(() => {
const store: any = {}
store.cachedProps = props
store.handlers = Object.keys(realHandlers).reduce(
(acc: {}, key) => ({
...acc,
[key]: (...payload) => realHandlers[key](store.cachedProps)(...payload)
}),
{}
)
return store
})
state.cachedProps = props
return { ...props, ...state.handlers }
}
The "Smart/Presentational Components" section of readme says that pipe(withProps({}), Component)
is a supported use case.
The implementation of pipe()
is concise and elegant. Unfortunately it doesn’t work when the supplied Component was created by e.g. React.forwardRef()
and thus is not a function but an object.
Could you add support for such components as well?
I actually had thought of starting a project like this when I saw the announcement that Recompose is being discontinued. We use Recompose heavily at my company and while I love the idea of the hooks proposal, we have a ton of Recompose in our apps that can not be easily converted to hooks, so I see something like this as a path forward. I'm curious if you have any ideas about what your biggest needs are for contributions, whether that's getting more parity with Recompose, needing more documentation, examples, tests, code, Flow and Typescript typings, etc...
Whatever you feel like your needs might be, I would love to jump in and start helping out because I see this project as exactly what we need going forward.
Would this be a welcome addition?
There is no github link to this package on the npm package page - https://www.npmjs.com/package/@synvox/rehook
Also, i really like the ideas and direction of this package!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.