08-26-2018 11:39
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

08-26-2018 11:39
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I am trying to implement a toggle in my settings but I keep getting a reference error for not being defined and I have no idea why:
in index.jsx:
function mySettings(props) {
return (
<Page>
<Section>
<Toggle
settingsKey="toggle"
label="Manually Set High & Low Threshold?"
/>
<TextInput
label="High threshold"
settingsKey="highThresholdIn"
disabled={!(props.settings.toggle === "true")}
/>
<TextInput
label="Low threshold"
settingsKey="lowThresholdIn"
disabled={!(props.settings.toggle === "true")}
/>
</Section>
</Page>
);
}
registerSettingsPage(mySettings);
and in index.js:
import * as messaging from "messaging";
import { encode } from 'cbor';
import { settingsStorage } from "settings";
import { me } from "companion";
...
if(settingsStorage.getItem( 'toggle' )) { manualHighLow = JSON.parse(settingsStorage.getItem( 'toggle' )); console.log("manual high low: " + manualHighLow) } else { manualHighLow = false; }
The error Im getting is:
ReferenceError: toggle is not defined settings.settingsStorage.onchange at companion/index.js:336,30 t.e.dispatchEventToListener at companion-runtime:/bootstrap.js:16,3910 t.e.dispatchEvent at companion-runtime:/bootstrap.js:16,3427 ? at undefined:1,37 EventEmitter.electron.ipcRenderer.on at C:\Users\xylotek\AppData\Local\Programs\@fitbitsimulator\resources\electron.asar\renderer\init.js:63,28 emitMany at events.js:146,13 EventEmitter.emit at events.js:223,7
Any ideas?
Thanks!

09-01-2018 10:13 - edited 09-01-2018 10:14
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


09-01-2018 10:13 - edited 09-01-2018 10:14
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
What does the onchange event look like in your companion/index.js?
settings.settingsStorage.onchange at companion/index.js:336,30

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

09-01-2018 12:47
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Hi Jon,
Thanks for the reply. I've since played around with it and got it to work. I cant recall what the onchange looked like at the time but playing around with the name of the key to something else seemed to work for whatever reason.

