Using React and Javacript, is it acceptable to add a custom property to props.location
when passing it via props.history.push
? e.g.
this.props.history.push({
pathname: '/someurl',
state: {smallObject: myObject},
customProperty : myBiggerObject
});
And then at the component that loads at /someurl, I can load:
let myBigObj = this.props.location.customProperty;
This appears to work, and I'm asking if it's "okay" to do? I am concerned that I may be overlooking something within Javascript or React that I am unaware of.
I would pass customProperty within the state property if the object that I was passing was sufficiently small. It isn't: it exceeds the 640k limit mentioned here, and I get an error indicating that data can not be cloned if I pass myBiggerObject
in the state
property.