overleaf/services/web/frontend/stories/utils/with-context-root.js
Alf Eaton 7c97f8ab6e Switch to new JSX runtime (#4225)
* Use new JSX runtime and update Babel Node target
* Update .eslintrc
* Remove React imports

GitOrigin-RevId: 559de0267f8f2934c56a860ea8701bb522aa861a
2021-06-24 02:06:59 +00:00

21 lines
588 B
JavaScript

import { ContextRoot } from '../../js/shared/context/root-context'
// Unfortunately, we cannot currently use decorators here, since we need to
// set a value on window, before the contexts are rendered.
// When using decorators, the contexts are rendered before the story, so we
// don't have the opportunity to set the window value first.
export function withContextRoot(Story, scope) {
const ide = {
...window._ide,
$scope: {
...window._ide.$scope,
...scope,
},
}
return (
<ContextRoot ide={ide} settings={{}}>
{Story}
</ContextRoot>
)
}