question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

rememberedState of undefined - React

See original GitHub issue

Versions:

  • @inertiajs/inertia version: ^0.10.1
  • @inertiajs/inertia-react version: ^0.7.1

Describe the problem:

Try use useRemember hook but return error “rememberedState of undefined”

Steps to reproduce:

Into component try use an example displayed in section “Remembering state”

image

Error image

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:7
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
BjornDCodecommented, Aug 31, 2021

We experienced the same issue so I did some digging. It only happens on the first page load. If I navigate to the page using useRemember from another page it loads fine.

The issue appeared when we switched from the old rendering method (directly rendering App) to using createInertiaApp.

It appears the useRemember hook runs before Inertia is initialised. useRemember calls Inertia.remember internally. The remember method relies on this.page being set on the Inertia instance. This happens when the init method is called, which happens in createInertiaMethod. When I log from useRemember and init it seems like useRemember is called before the init method.

Screenshot 2021-08-31 at 13 16 50
2reactions
rdgoutcommented, Oct 7, 2021

@reinink @claudiodekker any chance you or claudio can take a look at this? The remember functionality of useForm is basically not working, at all.

Read more comments on GitHub >

github_iconTop Results From Across the Web

inertia-react@0.8.0
inertia-react@0.8.0 ... "rememberedState of undefined" occurred on visits where useRemember was used (#949); useForm overload types were ...
Read more >
React State giving undefined, new to react - Stack Overflow
It looks like you're getting undefined while the data is loading (as the data isn't there yet and it's therefore undefined), you're printing ......
Read more >
Persisent children with tabbed pages with Inertia.js and React
I am trying to implement tabbed pages with Inertia.js and React. An example of this is seen ... And could you perhaps nest...
Read more >
React JS UNDEFINED Solution | Reactjs Learning - YouTube
As a React JS developer, have you encountered such errors?- TypeError: Cannot read property 'map' of undefined - Map is not a function-...
Read more >
Watch Out for Undefined State - Dave Ceddia
Quick quiz: When a React component loads data from the server in componentWillMount like this one below, what will it render? Beware Undefined...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found