recompose-scope
v0.7.0
Published
Compose React HOCs with a scope that restrict the props passing in and out
Downloads
10
Maintainers
Readme
recompose-scope
Compose React HOCs with a scope that restrict the props passing in and out.
composeWithScope(
...functions: Array<Function> | consumeProps | injectProps | exposeProps | exposeHandlers
): HigherOrderComponent
- Only specified outer props will pass into the scope.
(Specify by
consumProps
orinjectProps
) - Only specified inner props will send to the base component.
(Specify by
exposeProps
orexposeHandlers
) - All outer, not consumed props will skip the scope and pass through to the base component.
- Injected outer props will still send to the base component.
const consumeRoute = composeWithScope(
consumeProps({
location: propTypes.object,
match: propTypes.object,
history: propTypes.object,
}),
exposeProps(({ location, match }) => ({
path: location.pathname,
view: match.params.view,
id: match.params.id,
})),
exposeHandlers({
redirectToMenu: ({ history }) => () => history.push('/menu'),
}),
)
consumeProps
receives the same paramater asrecompose/setPropTypes
injectProps
receives the same paramater asrecompose/setPropTypes
exposeProps
receives the same paramater asrecompose/withProps
exposeHandlers
receives the same paramater asrecompose/withHandlers