0

Basically, I have an object name as currentUser generated from chatkit server. This object contains all the information as well as some methods of currently logged in user.

I want to pass this object as a prop to another component. I tried passing it to history.push by initially stringifying it, but after parsing the object at receiving end, I am not able to access the methods of the object. I know that json.stringify does exclude functions. Is there any other way that the stringify method does include the methods as well?

Can anyone suggest another way for passing down this object as props. I have seen something called localStorage. I am not sure how to use it. I would be grateful for any help.

shortstuffsushi
  • 2,271
  • 19
  • 33

1 Answers1

1

Try this one

this.props.history.push({
  pathname: '/your url',
  state: { anyKeyName: yourObject }
})
Muhammad Zeeshan
  • 4,608
  • 4
  • 15
  • 41
RamTn
  • 99
  • 5