01-08-2018 08:50
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

01-08-2018 08:50
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I am attempting to use the sample code given for the button settings in the documentation.
In Setttings - index.jsx I have the import statement for settingsStrorage and the code for the button:
<Button
list
label="Clear All Settings"
onClick={() => this.props.settingsStorage.clear()}
/>
However - when I execute I get in the consolelog TypeError: undefined is not an object (evaluating '_this.props')
I am able to use settingsStorage.clear() in the companion index.js.
I am sure I am missing something obvious but it is Monday...

01-09-2018 11:10 - edited 01-10-2018 12:05
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


01-09-2018 11:10 - edited 01-10-2018 12:05
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
You shouldn't need to import anything, but props needs to be in the function signature.
Try something like this:
function mySettings(props) { return ( <Page> <Section title={<Text bold align="center">Settings</Text>}> <Button list label="Clear All Settings" onClick={() => props.settingsStorage.clear()} /> </Section> </Page> ); } registerSettingsPage(mySettings);
[EDITED]

01-09-2018 12:41
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

01-09-2018 12:41
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I reduced my code to what you have and am still seeing the same issue.

01-09-2018 12:47
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


01-09-2018 12:47
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
It looks like you're mixing the Settings API (jsx) with the Companion API (js).
Remove the first 2 import lines, and confirm that this file is settings/index.jsx

01-10-2018 06:37
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

01-10-2018 06:37
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I have confirmed that I am working within the index.jsx file. Taking out the two import lines did not help. I am still getting the same TypeError:
I also started a new settings project and put a simple textInput in with the above code and got the same error in there as well.

01-10-2018 11:50
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


01-10-2018 11:50
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
In settings/index.jsx, this works for me:
<Button label="Create/Update" onClick={() => { props.settingsStorage.setItem('createAccount', 'true'); }} />
No 'import' statements or 'this' are required (or allowed).
Gondwana Software

