SolidJSS
SolidJSโ€ข16mo agoโ€ข
10 replies
mrVinicius

Store with const obj values passed to it does not update.

const initialViewable = {
    itemSource: true,
    itemCategory: true,
    itemType: true,
    inSearch: false,
    noFound: false,
};

const [viewable, setViewable] = createStore(initialViewable);

setViewable(initialViewable); // this does not work

setViewable({
    itemSource: true,
    itemCategory: true,
    itemType: true,
    inSearch: false,
    noFound: false,
}); // this does


Once a condition is met, I need to reset my component. I thought of doing this by using the initial values I used to instantiate a store. However, if I pass the constant directly, it doesn't work, but if I pass an object manually, it does. Why is that?
Was this page helpful?