0

I am at this path: http://localhost:3034/dashboard/one.

Now I want to pass a large object in another component <Edit/> that has an object and also change on the path to http://localhost:3034/dashboard/edit.

I don't want to use the next router to pass all objects with queries in URL. That one way, I know.

Example: router.push("/dashboard/edit/" + object)

I have data that pass from this slug: http://localhost:3034/dashboard/one to http://localhost:3034/dashboard/edit.

juliomalves
  • 42,130
  • 20
  • 150
  • 146
tirth1620
  • 154
  • 1
  • 8

1 Answers1

1

If you don't want to use the router to pass your data, a few options are left.

  • using a Reducer: handy and powerful, but lots of boilerplate to get it working

  • using a Context: powerful as well, a little tricky to master at first, and can trigger lots of redraws if not used properly

  • using the local storage: very easy to setup, but requires your data to be serializable, You can use libraries such as react-use to make your life easier

  • refetch your item in your edit page using an id: you could have your url like /dashboard/one/edit/ and fetch the data directly from that page instead of carrying the object around

Mentlegen
  • 988
  • 8
  • 11