How to inject a window variable in a storybook?
The window
you're trying to access is the iframe preview.
Try to access the window from outside the iframe, the Storybook window
.
window.parent.window.GLOBAL
I can add a preview-head.html
file in the __stories__
directory.
Inside which I have javascript like this:
<script>
var data = { };
window.GLOBAL = {
data: data
};
</script>
Documentation