react selector selectorfamily 차이

    [React.js] Recoil의 atom, atomfamily와 selector, selectorFamily에 대해서 알아보자

    ❗ atom atom은 단일 값 또는 객체를 나타내는 불변 상태를 정의하고 애플리케이션 전체에서 공유된다. 모든 컴포넌트에서 동일한 atom을 사용하며, 해당 atom에 대한 변경 사항은 모든 구독 컴포넌트에 자동으로 전파된다. ✔ 예제 import { atom, useRecoilState } from 'recoil'; const counterState = atom({ key: 'counterState', default: 0, }); function CounterComponent() { const [count, setCount] = useRecoilState(counterState); return ( Count: {count} setCount(count + 1)}>Increment ); } 해당 예제는 ..