03-29-2022 08:04
03-29-2022 08:04
What is the best way to populate values on the Settings page, if not input manually?
It works fine for the user entering data on the settings page, which gets sent to the companion, and then to the app, but the reverse doesn't seem to work at all.
EG.
In the JSX
<TextInput
label="Enter the place"
settingsKey="place"
defaultValue="Paris"
/>
In the companion [hard coded] as first line
settingsStorage.setItem("place", "Madrid");
When the Settings page appears "place" has no value. Neither Paris nor Madrid.
Author | ch, passion for improvement.
Answered! Go to the Best Answer.
03-29-2022 12:33
03-29-2022 12:33
In your setItem, that's probably not the correct format for the value that <TextInput> uses.
Use console.log to find out what a <TextInput> stores in settingsStorage, then craft your setItem to match it.
A possible gotcha is that setItem only takes string values.
03-29-2022 12:33
03-29-2022 12:33
In your setItem, that's probably not the correct format for the value that <TextInput> uses.
Use console.log to find out what a <TextInput> stores in settingsStorage, then craft your setItem to match it.
A possible gotcha is that setItem only takes string values.
03-29-2022 23:58 - edited 03-30-2022 00:05
03-29-2022 23:58 - edited 03-30-2022 00:05
03-30-2022 01:09
03-30-2022 01:09
@Guy_ No worries. I'm glad you didn't take issue with me giving you more homework instead of just serving up the answer (which I didn't know off the top of my head).
I learnt something too. I always use JSON.stringify when putting objects into settings, but your solution is nicer.
03-30-2022 01:16