Skip to content

Parity with recomposeΒ #23

@pfgray

Description

@pfgray

I'd like to have direct replacements for or at least an explanation of how one would emulate every hoc from recompose, as that library is so prevalent

I took a cursory glance at the documentation and came up with this graph:

emoji meaning
βœ… covered
🚧 feasible, not implemented yet
πŸ€” need to think on it
😧 😧
hoc explanation
βœ… mapProps() this is just cc.map(a => b)
βœ… withProps() this is just CC.of({})
πŸ€” withPropsOnChange()
πŸ€” withHandlers()
βœ… defaultProps() is just CC.of({})
βœ… renameProp() is just cc.map(a => b)
βœ… renameProps() is just cc.map(a => b)
βœ… flattenProp() is just cc.map(a => b)
βœ… withState()
πŸ€” withStateHandlers()
🚧 withReducer()
βœ… branch() is just fork()
βœ… renderComponent() is just fork(true ), maybe could add a special case?
βœ… renderNothing() is just fork(true, () => null
🚧 shouldUpdate()
βœ… pure() is just pure() … not sure this is a good one to promote, though?
βœ… onlyUpdateForKeys() is just pure()
πŸ€·β€β™€οΈ onlyUpdateForPropTypes()
🚧 withContext()
🚧 getContext()
βœ… lifecycle() withLifecycle()
😧 toClass()
βœ… toRenderProps()
βœ… fromRenderProps()

For the "handlers" hocs, I think it makes the most sense to just implement something like the useCallback hook, and then they are just different mappings/combinations of that chainable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions