React contexter
Use context with Higher Order Components for better testing and reuse.
The logic is simple: put the context
you want as props
.
; { return <button onClick= fromParent >Click Me!</button>;}; var ContextedComponent = ;
And that's it. MyComponent
can be tester with your favorite testing tools, just inject the right prop
and you're ready to go.
Install
just npm install --save react-contexter
as you normally do.
API
createContexter(contextTypes)
creates a wrapper function for creating context containers:
;var contexter = ; var ContextedComponentOne = ;var ContextedComponentTwo = ;
this can help you creating custom utility functions for your applications.
contexter(contextTypes, Component)
creates a contexter that injects contextTypes
and executes it with Component
.
; { return <button onClick= fromParent >Click Me!</button>;}; var ContextedComponent = ;