01-26-2024 06:42
01-26-2024 06:42
Hi! How is the way to set a color into "ColorSelect", selecting a value from a "Select" (All into index.jsx from settings). I had put onSelection on Select to set the color on the other component, but I don't know if set the string value or use json.stringify...
I need some help...
01-27-2024 06:45
01-27-2024 06:45
Finally I used this:
(background, backgroundGradient and foreground are color settings)
<Select
label={'Color'}
settingsKey="colorSelected"
options={[
{name: 'Background', value: 'background'},
{name: 'Background Gradient', value: 'backgroundGradient'},
{name: 'Foreground', value: 'foreground'}
]}
onSelection={({values}) => {
props.settingsStorage.setItem("selectedColor", props.settingsStorage.getItem(values[0].value));
}
}
/>
But I had to use the value without formatting to JSON to send to the watch:
function sendValue(key, val) {
if (val) {
sendSettingData({
key: key,
//value: JSON.parse(val)
value: val
});
}
}
01-27-2024 11:38
01-27-2024 11:38
JSON.parse() doesn't convert a value TO JSON format; it does the opposite. Perhaps you were thinking of JSON.stringify()?