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

[Feature Request] Integrate with HOCs. #135

Closed
rockmandash opened this issue Jul 4, 2018 · 2 comments
Closed

[Feature Request] Integrate with HOCs. #135

rockmandash opened this issue Jul 4, 2018 · 2 comments

Comments

@rockmandash
Copy link

Hello, first of all, thank you for this wonderful library.
This library and react-fns are my favorite librarys!
However, it's often to run into some situations that you need to access some property in lifecycle hoods that react-powerplug provides you.
If we can have HOC, the code will become much nicer like this.

export default withToggle(MyApp)

Thank you!

@TrySound
Copy link
Collaborator

TrySound commented Jul 4, 2018

Just wrap with component. This will prevent you from props pollution/overriding and will provide you type safety.

import { Toggle } from 'react-powerplug';

const InnerApp = () => null

const App = () => (
  <Toggle>
    {checkbox =>
      <Toggle>
        {modal =>
          <InnerApp checkbox={checkbox} modal={modal} />
        }
      </Toggle>
    }
  </Toggle>
)

@rockmandash
Copy link
Author

Thank you for your fast reply!
Yes, HOC can't do the example you provide.
Learned a lesson!

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

No branches or pull requests

2 participants