SolidJSS
SolidJSโ€ข3y agoโ€ข
3 replies
Mr Void

setState variable as path doesn't work

The following works
    setState("items", "collections", (collections: ItemCollection[]) =>
        [...collections].filter((collection) =>
            collection.id !== collection_id
        )
    )


However, this doesn't work, why? path is always one of the possible keys inside items object.
    setState("items", path, (collections: ItemCollection[]) =>
        [...collections].filter((collection) =>
            collection.id !== collection_id
        )
    )

ts error:
Argument of type 'string' is not assignable to parameter of type 'Part<ItemStore, keyof ItemStore>'. ts(2345)
Was this page helpful?