with-context-root.js 614 B

12345678910111213141516171819202122
  1. import React from 'react'
  2. import { ContextRoot } from '../../js/shared/context/root-context'
  3. // Unfortunately, we cannot currently use decorators here, since we need to
  4. // set a value on window, before the contexts are rendered.
  5. // When using decorators, the contexts are rendered before the story, so we
  6. // don't have the opportunity to set the window value first.
  7. export function withContextRoot(Story, scope) {
  8. const ide = {
  9. ...window._ide,
  10. $scope: {
  11. ...window._ide.$scope,
  12. ...scope,
  13. },
  14. }
  15. return (
  16. <ContextRoot ide={ide} settings={{}}>
  17. {Story}
  18. </ContextRoot>
  19. )
  20. }