Is it possible to set a Global variable (`globalTypes`) from within a Story?
See original GitHub issueI managed to add a toolbar icon that sets my locale for my Storybook app, thanks to https://storybook.js.org/docs/react/essentials/toolbars-and-globals#gatsby-focus-wrapper documentation 🎉
But, when I manipulate my “change language button” nothing happens (unsurprisingly), because it cannot change the Storybook global variable state. Is there a way to set my locale
variable? Through hooks maybe? I couldn’t find any documentation about this.
Video showcasing the behavior difference: https://youtu.be/nbvkXpRWz24
It’s not highly critical, but if there is a way for me to make the story preview behave as in the main app, that’d be great!
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Create a global variable in TypeScript - Stack Overflow
I want to be able to call log.Debug from any file without having to import and create objects.) typescript.
Read more >Theme switching with globals and parameters in decorators
In the previous lesson, we created a decorator to add theme support to Storybook. Although it's working well, in order to switch the...
Read more >Generate Code for Global Data - MATLAB & Simulink
Declare Global Variables. When using global data, you must first declare the global variables in your MATLAB code. Consider the use_globals function that...
Read more >Can you change a global variable's value from within a function?
This is a conceptual question rather than one specifically about the lesson. I understand the idea that a local variable is independent of...
Read more >How to Avoid Using Global Cypress Variables - Gleb Bahmutov
Avoid clashing global types between Cypress and Jest by using local-cypress library. Global variables are the worst thing in programming, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
There is a
useGlobals
hook but I haven’t tried it in a story:https://github.com/storybookjs/storybook/blob/next/lib/api/src/index.tsx#L448-L455
I’ll give it a try when I find some time and keep you updated. Thanks!