Skip to content

Error when deploying on vercel #856

Answered by ahohnsen
VanessaDiBella asked this question in Web
Discussion options

You must be logged in to vote

I took a closer look at your app. When you try to edit a workout—meaning you’re on the edit page—and then reload the page, an error occurs saying that workouts is undefined.

When you refresh the edit page, the browser makes a full HTTP request to the server for that specific URL. This results in a fresh load of the entire page:

  • The useSWR hooks start fetching data asynchronously from their respective APIs, but initially, the data is undefined until the fetch completes.
  • During this time, if your component tries to access workouts or exercises while they are still undefined, you will encounter errors.

I suggest to add an early return to ensure that your component does not try to access da…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@EmmaDir
Comment options

@VanessaDiBella
Comment options

@ahohnsen
Comment options

Answer selected by ahohnsen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Web
Labels
None yet
3 participants