#Persist Filter State in React Application Using localStorage

16 messages · Page 1 of 1 (latest)

distant salmon
#

@night gulch Not seeing anything obviously wrong from that snippet: does the data appear to be correctly stored in localStorage from the dev tools?

night gulch
#

@distant salmon no , it doesnt

distant salmon
#

@night gulch Looks like you've got an infinite render loop somewhere, where some effect causes a state change that causes the same effect to fire again.

#

I don't think that just writing to local storage should cause that - that shouldn't cause a rerender, so it may be somewhere else in your codebase.

#

Switching to the non-minified version of React would probably help a lot for debugging.

night gulch
distant salmon
#

Doesn't look like you're conditionally rendering? object.config.message is the condition that shows the "no-data-message"

#

Also, filteredData.length > 0 || searchTerm ? filteredData : data looks like it falls back to data when filteredData is empty.

#

Maybe you can reproduce it on a code sandbox? Hard to debug things just looking at unformatted code

night gulch
#

yea just 1 moment pls

distant salmon
#

Doesn't have to be the real project, just has to reproduce the error

#

(Also, trying to simplify and reproduce a problem often solves it)

#

Looks like you have to hit share; getting "sandbox not found, you don't have permission to access this"

distant salmon
#

That doesn't run?

#

Doesn't have to be the real project, just has to reproduce the error
The point is to actually show the behavior you're trying to solve. Like I said, you may have to simplify.