Pass typescript class as a parameter to navigation between pages

Hi,

As a newbee to TypeScript: I have created a custom typescript class and I need to pass an instance of it from one page to the other. Is it even possible?

I know I can pass JsonObject using the useNavigate hook for example but this will not include all of the class functionalities.

How would you handle this? Should it just be as a single page with different components rendered based on the state of it and using “global” page variable with the class instance?

Gil.

Hi @gilgi

This is a question about how to manage states within React.

If you don’t have a complex component structure, you can share the states between components by lifting the state up and passing props. Please check out this page for more detailed examples: Sharing State Between Components – React

For more complex component structure I would suggest that you use context: Passing Data Deeply with Context – React

BR,

Sini