Skip to content

Commit

Permalink
state.js: do not call an undefined function
Browse files Browse the repository at this point in the history
When changing page in a stateless app, there is no state to set `is_hydrated: False`
  • Loading branch information
masenf committed Apr 2, 2024
1 parent b4d0163 commit c78884b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion reflex/.templates/web/utils/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,12 @@ export const useEventLoop = (

// Route after the initial page hydration.
useEffect(() => {
const change_start = () => dispatch["state"]({is_hydrated: false})
const change_start = () => {
const main_state_dispatch = dispatch["state"]
if (main_state_dispatch !== undefined) {
main_state_dispatch({is_hydrated: false})
}
}
const change_complete = () => addEvents(onLoadInternalEvent());
router.events.on("routeChangeStart", change_start);
router.events.on("routeChangeComplete", change_complete);
Expand Down

0 comments on commit c78884b

Please sign in to comment.