I want to set a state value to a variable on page load in my Retool app. Currently, I wrote a JS query with the “Run on page load” option enabled, but I noticed that the page components don’t render until this query (and its event handler) finishes running. This makes the page appear blocked or delayed while the JS executes. How can I initialize a state value on page load ensuring all components rendered??
I tested this out and it looks like there is somewhat of a delay on page load while the JS query runs, before the components render.
It depends on your set up and goal. Does the JS query that sets the value of a variable effect the data in your app's components or how the components look?
You could change the JS query to run later, triggered by a different event or on success of another query running, after the components render if it isn't going to change how the app looks.
If the JS query and variable do change how the app looks, this would likely lead to the app rendering then flashing as it changes. If this is the case, you would likely want to keep the 'run on page load' so that the app takes longer to load instead of loading slightly faster then changing.
I do not believe it is possible to have “Run on page load” queries not effect the timeline of what occurs as the app renders, but those queries could potentially be made faster or more efficient with optimizing.
Just wanted to follow up if you had more details on your use case for seeing if we could find a work around to accomplish your goal.