03-29-2022 08:04
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


03-29-2022 08:04
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
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.

Accepted Solutions
03-29-2022 12:33
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


03-29-2022 12:33
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
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.
Gondwana Software

03-29-2022 12:33
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


03-29-2022 12:33
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
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.
Gondwana Software

03-29-2022 23:58 - edited 03-30-2022 00:05
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


03-29-2022 23:58 - edited 03-30-2022 00:05
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
03-30-2022 01:09
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


03-30-2022 01:09
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
@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.
Gondwana Software
03-30-2022 01:16
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


03-30-2022 01:16
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
