Local Storage List
Simple observable list that can be subscribed to, in React, using Hooks. State is automatically synced to the localStorage.
yarn add @corets/local-storage-listnpm install --save @corets/local-storage-listQuick Start
import React from "react"
import { createLocalStorageList } from "@corets/local-storage-list"
import { useList } from "@corets/use-list"
const Example = () => {
const list = useList(() => createLocalStorageList("storageKey", ["apple", "banana"]))
const addFruit = () => list.add("pineapple")
return (
<div>
Fruits: {list.get().join(",")}
<button onClick={addFruit}>Add fruit</button>
</div>
)
}createLocalStorageList()
Last updated
Was this helpful?