A memoized wrapper around React.createContext. Used by One App as a dependency to pass React context between Holocron modules without external usage.
Want to get paid for your contributions to create-shared-react-context
?
Send your resume to oneamex.careers@aexp.com
- Memoized wrapper around React.createContext
$ npm install --save create-shared-react-context
import createSharedReactContext from 'create-shared-react-context';
const context = createSharedReactContext({}, 'someIdentifier');
createSharedReactContext
takes two arguments: defaultValue
and key
.
defaultValue
is the same default value that would be used in createContext
.
key
is the identifier used to ensure that any subsequent call of createSharedReactContext
will return any previous created context with the same identifier.
In a modular application, sharing functionality between bundled modules with their own dependencies can be done in a myriad of ways. If one wanted to be able to pass functionality using React Context, but each module has their own instance of the dependency creating that context, the Provider used at the top would fail to pass context down to the Consumer, as the reference would be different. You could declare that dependency as an external, so that the reference used by each module would be shared, but sometimes a dependency may not require a separate instance to function.
These commands will be automatically run during normal git operations like committing code.
pre-commit
This hook runs npm test
before allowing a commit to be checked in.
commit-msg
This hook verifies that your commit message matches the One Amex conventions. See the commit message section in the contribution guidelines.
Any contributions made under this project will be governed by the Apache License 2.0.
This project adheres to the American Express Community Guidelines. By participating, you are expected to honor these guidelines.