'problem with passing multiple state with React history.push()

I try to pass more then one arg with history.push(). Something like this:

history.push({
                pathname: '/sailing-data/',
                state: {
                  backPath: history.location.pathname,
                  dataIdToOpenModal: DataIds.SpeedWindApp
                }
              });

But when I examine that later like this:

console.log(history.location.state, 'bckpth');

I receive null. Interestingly, when pass only one arg

history.push({
                pathname: '/sailing-data/',
                state: {
                  backPath: history.location.pathname
                }
              });

I receive expected output.What could be a reason for that behaviour? Is that syntax issue? I have not found many examples.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source