1# `useSelector()` hook 2 3With `useSelector` React hook you specify a selector function, which will pick specific 4data from the state. *Your component will update only when that specific part of the state changes.* 5 6```tsx 7const selector = state => state.isDarkMode; 8const Demo = () => { 9 const isDarkMode = useSelector(selector); 10 return <div>{isDarkMode ? '' : '☀️'}</div>; 11}; 12``` 13 14As an optional second argument for `useSelector` you can provide a `comparator` function, which 15compares currently selected value with the previous and your component will re-render only if 16`comparator` returns `true`. By default it uses [`fast-deep-equal`](https://github.com/epoberezkin/fast-deep-equal). 17 18``` 19useSelector(selector, comparator?) 20``` 21