react-router icon indicating copy to clipboard operation
react-router copied to clipboard

history.push does not work on Firefox if passed state is a big JSON object

Open borabuilds opened this issue 6 years ago • 1 comments

Version

5.1.2

Test Case

https://codesandbox.io/s/peaceful-sky-eegmr

Steps to reproduce

Click the button on Firefox

Expected Behavior

Button should navigate to Component2

Actual Behavior

It throws NS_ERROR_ILLEGAL_VALUE error on Firefox.

When button in Component1 is clicked, it calls history.push function. If passed state to history.push function is a big JSON object, Firefox throws NS_ERROR_ILLEGAL_VALUE exception.

This error occurs only on Firefox. Chrome, Safari and Opera work properly.

I think it is because of some limitations of Firefox. Please see: https://developer.mozilla.org/en-US/docs/Mozilla/Errors

NS_ERROR_ILLEGAL_VALUE (0x80070057) An argument supplied to a method was not valid, for instance a null value was supplied as an argument which does not allow null values, or a value was out of range.

borabuilds avatar Jan 21 '20 13:01 borabuilds

This isn't something we can really fix. You shouldn't be using location state with so much data anyways. That's not what it's intended for. Use another state container separate from Router and just point location.state to some path in that container.

timdorr avatar Jan 21 '20 14:01 timdorr