with-context-root.js 588 B

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