UNPKG

@ohm-vision/react-storage

Version:

Extension to React to interact with native Window Storage object

16 lines (15 loc) 424 B
import { useStorage } from "./use-storage"; /** * Default Date storage which defaults the `convert` to `Date` initializers * @param props * @returns */ export function useDateStorage(props) { if (!props.convert) { props.convert = { fromStorage: function (v) { return new Date(v); }, toStorage: function (v) { return v.toISOString(); } }; } return useStorage(props); }