Fitbit Product Experts Alumni are retired members of the Fitbit Product Expert Program. Learn more
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.
Best AnswerIn 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.
Best AnswerIn 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.
Best Answer
Fitbit Product Experts Alumni are retired members of the Fitbit Product Expert Program. Learn more
@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.
Fitbit Product Experts Alumni are retired members of the Fitbit Product Expert Program. Learn more