You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm learning AtomWithHashOptions. Does this type make sense? If so, please add it at the next opportunity.
export type AtomWithHashOptions<Value> = {
/**
* A function to serialize the value before storing it in the URL hash.
* The serialized string will be decoded by the `deserialize` function.
* Default: `JSON.stringify`
*/
serialize?: (val: Value) => string;
/**
* A function to deserialize the value retrieved from the URL hash.
* The deserialized value will be used as the initial value of the atom.
* If the deserialized value is `NO_STORAGE_VALUE`, the atom will be initialized with the `initialValue`.
* Default: `(str) => NO_STORAGE_VALUE`
*/
deserialize?: (str: string | null) => Value | typeof NO_STORAGE_VALUE;
/**
* A boolean flag that indicates whether to use `window.history.replaceState` instead of `window.location.hash`.
* When this flag is set to `true`, the URL hash will be replaced instead of being added to the browser history.
* Note: This flag is deprecated in favor of using `setHash` with `"replaceState"`.
* Default: `false`
* @deprecated Use `setHash` with 'replaceState' instead
*/
replaceState?: boolean;
/**
* A function that will be called when the URL hash changes.
* The callback should update the atom value with the new hash value.
* Default: `(callback) => { window.addEventListener("hashchange", callback); return () => window.removeEventListener("hashchange", callback); }`
* @returns A function that can be called to unsubscribe from the changes.
*/
subscribe?: (callback: () => void) => () => void;
/**
* A function to set the URL hash.
* By default, it sets the hash using `window.location.hash`.
* When `replaceState` is set to true, it uses `window.history.replaceState` instead.
* If a function is provided, it will be used instead.
* The searchParams argument is the stringified version of the atom value.
* Default: `"default"`
* Options:
* - `"default"`: Sets the hash using `window.location.hash`.
* - `"replaceState"`: Sets the hash using `window.history.replaceState`.
* - `(searchParams: string) => void`: A custom function that will be used to set the hash.
*/
setHash?: "default" | "replaceState" | ((searchParams: string) => void);
};
The text was updated successfully, but these errors were encountered:
I'm learning AtomWithHashOptions. Does this type make sense? If so, please add it at the next opportunity.
The text was updated successfully, but these errors were encountered: