selector 선언과 사용

Tags
설명
 

selector 선언

const charCountState = selector({ key: 'charCountState', // unique ID (with respect to other atoms/selectors) get: ({get}) => { const text = get(textState); return text.length; }, });
 

selector 사용

function CharacterCount() { const count = useRecoilValue(charCountState); return <>Character Count: {count}</>; }