Forum Discussion
Stores settings and values
Hi Anonymous,
If you want to store via the visual properties, you will need to create a text/string-valued property that can store your object as a string representation (e.g., through JSON.stringify) and save it via persistProperties. You can omit the property from being displayed when you build the properties pane for your visual, and it will still work; it just has to be valid for your visual capabilities. I have a feature flag for debugging purposes which will render it when I want to inspect it this way, but that's up to you as to whether you want to do something similar.
When it comes to retrieval, you will need to deserialize this to a valid object (e.g., through JSON.parse) when the visual is re-initialized.
I believe that you can use local storage also, but it's not something I have experience with to advise further. Anecdotally, the folks I know who use it get on OK with it.
Regards,
Daniel
Hello dm-p ,
I try to use persistProperties in my code to store the visual properties and React.useState value, but I don't know how to use it. I don't have any example for my code. Can you share me some infor how to use this persistProperties ?