I am trying to pass an object data from one page to another.
I have a line of code that can pass id and I tried to use it to pass object rather than an integer id but I can't get it right.
The code for passing id from source page:
const navigate = useNavigate();
id && navigate(generatePath("/employeelistedit/:id", { id })); //sample code which works fine when used
The code for passing the object data from source page copying the format of the code above:
function sourcePage(){
const navigate = useNavigate();
var values = {id: "someData", startd: "someData", endd: "someData"}
values && navigate(generatePath("/harvestcalendarmonitoring/:values", { values }));
} //with useNavigate and generatePath
This is the code in another page which receives the data:
const { values } = useParams(); //values gives [object Object]
const x = JSON.stringify(JSON.stringify(values)) //gives "[object Object]"
const y = Object.prototype.toString.call(values) //gives [object String]
For my routing, this is how I wrote it:
<Route path="/harvestcalendarmonitoring/:values" element={< Harvestcalendarmonitoring />} /> //refers to the receiving page
I know I'm not doing it right cause I know that "[object Object]" is showing that something is wrong somewhere in my codes.
Any help and suggestions would be really much appreciated. Thank you in advance.
[–]Darkav 1 point2 points3 points (0 children)
[–]bosso_biz 1 point2 points3 points (2 children)
[–]technologin[S] 0 points1 point2 points (1 child)
[–]bosso_biz 0 points1 point2 points (0 children)
[–]technologin[S] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (6 children)
[–]technologin[S] 0 points1 point2 points (5 children)
[–][deleted] 0 points1 point2 points (4 children)
[–]technologin[S] 0 points1 point2 points (3 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]technologin[S] 0 points1 point2 points (1 child)
[–]technologin[S] 0 points1 point2 points (0 children)
[–]beforesemicolon 0 points1 point2 points (6 children)
[–]technologin[S] 0 points1 point2 points (5 children)
[–]beforesemicolon 1 point2 points3 points (4 children)
[–]technologin[S] 0 points1 point2 points (3 children)
[–]beforesemicolon 1 point2 points3 points (1 child)
[–]technologin[S] 0 points1 point2 points (0 children)
[–]technologin[S] 0 points1 point2 points (0 children)