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,7Any ideas?
Thanks!
Best Answer
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
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.
Best Answer