We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
WIP branch exists here: https://github.com/fahad19/proppy/tree/proppy-react-hook
React hooks will land soon in stable version, and currently already available in alpha version.
More info: https://reactjs.org/docs/hooks-intro.html
For the examples below, we will be using these providers:
import React from 'react'; import { ProppyProvider } from 'proppy-react'; const providers = { foo: 'foo value', bar: 'bar value', }; export default function Root() { return ( <ProppyProvider providers={providers}> <MyComponent /> </ProppyProvider> ); }
And the sample factory:
import { compose, withProps, withState, shouldUpdate } from 'proppy'; const P = compose( withProps((props, providers) => {}), withState('counter', 'setCounter', 0), shouldUpdate(props => props.counter % 2 === 0), );
useProppy
Using Proppy factory inside Components:
import React from 'react'; import { useProppy } from 'x'; // new package const P; // factory export default function MyComponent(props) { const { counter, setCounter } = useProppy(P, props); return ( <p onClick={() => setCounter(counter + 1)}> {counter} </p> ); }
useProviders
Access all the providers:
import React from 'react'; import { useProviders } from 'x'; export default function MyComponent(props) { const { foo, bar } = useProviders(); return <p></p>; }
useProvider
Access individual providers:
import React from 'react'; import { useProvider } from 'x'; export default function MyComponent(props) { const foo = useProvider('foo'); return <p></p>; }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
WIP branch exists here: https://github.com/fahad19/proppy/tree/proppy-react-hook
Background
React hooks will land soon in stable version, and currently already available in alpha version.
More info: https://reactjs.org/docs/hooks-intro.html
Set up
For the examples below, we will be using these providers:
And the sample factory:
Usage APIs
useProppy
Using Proppy factory inside Components:
useProviders
Access all the providers:
useProvider
Access individual providers:
The text was updated successfully, but these errors were encountered: