● monkey-patches `theme` into user defined context
Invariant Violation: ContextWrapper.getChildContext(): key "userTheme" is not defined in childContextTypes.
at invariant (node_modules/fbjs/lib/invariant.js:44:15)
at ReactCompositeComponentWrapper._processChildContext (node_modules/react-dom/lib/ReactCompositeComponent.js:520:90)
at ReactCompositeComponentWrapper.performInitialMount (node_modules/react-dom/lib/ReactCompositeComponent.js:371:105)
at ReactCompositeComponentWrapper.mountComponent (node_modules/react-dom/lib/ReactCompositeComponent.js:258:21)
at Object.mountComponent (node_modules/react-dom/lib/ReactReconciler.js:46:35)
at node_modules/react-dom/lib/ReactServerRendering.js:45:36
at ReactServerRenderingTransaction.perform (node_modules/react-dom/lib/Transaction.js:140:20)
at renderToStringImpl (node_modules/react-dom/lib/ReactServerRendering.js:43:24)
at renderToStaticMarkup (node_modules/react-dom/lib/ReactServerRendering.js:83:10)
at render (node_modules/enzyme/build/render.js:88:55)
at Object.<anonymous> (src/__tests__/theme-provider.js:152:22)
at Promise.resolve.then.el (node_modules/p-map/index.js:42:16)
at process._tickCallback (internal/process/next_tick.js:109:7)
Created
May 23, 2017 19:29
-
-
Save atticoos/96955b52c1f29962b4d5f1cf13ed6202 to your computer and use it in GitHub Desktop.
attempting to set `context` with Providers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test('monkey-patches `theme` into user defined context', () => { | |
const Child = glamorous.div((props, context) => ({ | |
fontSize: context.theme.fontSize, | |
color: context.userTheme.color, | |
})) | |
Child.contextTypes = { | |
userTheme: PropTypes.object, | |
} | |
const context = { | |
userTheme: { | |
color: 'blue', | |
}, | |
} | |
expect( | |
render( | |
<ThemeProvider theme={{fontSize: 36}}> | |
<Child /> | |
</ThemeProvider>, | |
{context}, | |
), | |
).toMatchSnapshotWithGlamor() | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment