passionui / support

0 stars 0 forks source link

[WARN] Non-serializable values were found in the navigation state #19

Closed zhafri-shafiq closed 4 years ago

zhafri-shafiq commented 4 years ago

on Filter screen, onNavigateLocation() and onNavigateArea() are passing function setLocation() and setArea() in navigation, which triggered warning:

WARN Non-serializable values were found in the navigation state. Check: ChooseLocation > params.onApply (Function) This can break usage such as persisting and restoring state. This might happen if you passed non-serializable values such as function, class instances etc. in params.

Is there any workaround or solutions that i can do to achieve expected behavior? And i would not disable the warning because, i might have deep link later on which could break the state persist.

eldano1995 commented 4 years ago

I could tell you about my approach to that problem if you'd like @zhafri-shafiq

zhafri-shafiq commented 4 years ago

@eldano1995 yes please tell me. this will help other people that may come here to find solution as well

eldano1995 commented 4 years ago

@eldano1995 yes please tell me. this will help other people that may come here to find solution as well

The solution we came up with applies to all screens that are like ChooseLocation (screens with a list of items, where you select one, and the a callback function is called when pressing on apply). The solution involves using Redux. Esencially:

I think that's it. Any doubts, leave a comment. Sorry if I didn't explain it well.

eldano1995 commented 4 years ago

I've got another solution, that might not be that "fancy"

zhafri-shafiq commented 4 years ago

@eldano1995 basically moving the setter function from component to redux? I get it. I think this is considered solved for this issue. I just had a different scenario, example: a tv shows has many seasons. in tv show detail screen, there is a button to a list of seasons. currently, I passed the setter function in navigation to the list of seasons, and call that function when navigating back. which would throw this warning. I could move it to redux, but there will be a lot of tv shows. so, I just don't think that would be okay. what do you think?

anyway, thank you for your concern. I am closing this issue.

eldano1995 commented 4 years ago

@eldano1995 basically moving the setter function from component to redux? I get it. I think this is considered solved for this issue. I just had a different scenario, example: a tv shows has many seasons. in tv show detail screen, there is a button to a list of seasons. currently, I passed the setter function in navigation to the list of seasons, and call that function when navigating back. which would throw this warning. I could move it to redux, but there will be a lot of tv shows. so, I just don't think that would be okay. what do you think?

anyway, thank you for your concern. I am closing this issue.

Why wouldn't that be OK?? Give me details about the concern, to see if there's something I'm missing, or to help you out if that's not the case.