Split from https://github.com/twentyhq/twenty/pull/4518 Co-authored-by: Charles Bochet <charlesBochet@users.noreply.github.com>
19 lines
344 B
TypeScript
19 lines
344 B
TypeScript
import { atom, AtomEffect } from 'recoil';
|
|
|
|
export const createState = <ValueType>({
|
|
key,
|
|
defaultValue,
|
|
effects,
|
|
}: {
|
|
key: string;
|
|
defaultValue: ValueType;
|
|
effects?: ReadonlyArray<AtomEffect<ValueType>>;
|
|
}) => {
|
|
const recoilState = atom<ValueType>({
|
|
key,
|
|
default: defaultValue,
|
|
effects,
|
|
});
|
|
return recoilState;
|
|
};
|