refactor: move createState to twenty-ui (#4716)

Split from https://github.com/twentyhq/twenty/pull/4518

Co-authored-by: Charles Bochet <charlesBochet@users.noreply.github.com>
This commit is contained in:
Thaïs
2024-04-01 13:22:51 +02:00
committed by GitHub
parent a3e5cf37b0
commit 8ae6af6bd7
66 changed files with 86 additions and 64 deletions

View File

@ -1,3 +1,4 @@
export * from './components';
export * from './display';
export * from './theme';
export * from './utilities';

View File

@ -0,0 +1 @@
export * from './state/utils/createState';

View File

@ -0,0 +1,18 @@
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;
};