Hi, I need to be able to init a page based off cookie settings.
So back in the day you could just do a <body onload="func()" />
I've seen different ways to do this in React with props and querying the virtual DOM, but what is the best way to do this in GatsbyJS in particular?
Right now I just have a quick hack with <body onLoad={myFunc()} /> and then I set a bool to return every time a link is clicked.
Depending on when exactly you want to get your callback called you can use one of those Gatsby browser APIs:
onClientEntry - this will be first thing that runs (before mounting react application)onInitialClientRender - this will run after react application has mountedI'm not sure what you want to do there, so if those won't work for you, please add more information so we talk about specific use case.
Thanks a lot this should be useful. Haven't had time to try it, but seems like it should work.
Most helpful comment
Depending on when exactly you want to get your callback called you can use one of those Gatsby browser APIs:
onClientEntry- this will be first thing that runs (before mounting react application)onInitialClientRender- this will run after react application has mountedI'm not sure what you want to do there, so if those won't work for you, please add more information so we talk about specific use case.