Skip to content

Commit

Permalink
LanguageScreen [nfc]: Inline handleFilterChange.
Browse files Browse the repository at this point in the history
This wasn't doing any real work, and it's a bit less code to inline
it.

We're not losing the `useCallback`'s optimization here. The
`useCallback` doc has a "Note" box, after introducing the example of

```
const [state, setState] = useState(initialState);
```

The "Note" box says,

> React guarantees that `setState` function identity is stable and
> won’t change on re-renders.

[1] https://reactjs.org/docs/hooks-reference.html#usecallback
  • Loading branch information
chrisbobbe authored and gnprice committed Jul 7, 2021
1 parent 5a4aa76 commit 4aedc4c
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/settings/LanguageScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ export default function LanguageScreen(props: Props) {
[dispatch],
);

const handleFilterChange = useCallback((f: string) => setFilter(f), []);

return (
<Screen search searchBarOnChange={handleFilterChange} scrollEnabled={false}>
<Screen search searchBarOnChange={setFilter} scrollEnabled={false}>
<LanguagePicker value={locale} onValueChange={handleLocaleChange} filter={filter} />
</Screen>
);
Expand Down

0 comments on commit 4aedc4c

Please sign in to comment.