-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- doc site performance - bump deps - migrate to clsx - add redux docs
- Loading branch information
1 parent
a36a3b2
commit 009be5e
Showing
16 changed files
with
23,298 additions
and
10,643 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
id: redux | ||
title: Redux | ||
--- | ||
|
||
In lieu of using custom hooks, you should control state yourself when integrating with external | ||
state systems like redux, flux, etc. | ||
|
||
<!-- prettier-ignore --> | ||
:::caution | ||
Rarely is there a benefit to using local component state with redux. | ||
Generally speaking we should avoid this as much as possible and control | ||
PCR components using state providers rather than `useCheckboxState` and friends. | ||
::: | ||
|
||
Here's a quick example of using redux with PCR: | ||
|
||
```tsx | ||
import { useSelector, useDispatch } from 'react-redux'; | ||
|
||
function App() { | ||
const accepted = useSelector(state => state.accepted); | ||
const dispatch = useDispatch(); | ||
|
||
const onChange = React.useCallback(e => { | ||
dispatch({ type: 'tac', actions: { accepted: e.currentTarget.checked } }); | ||
}, []); | ||
|
||
return ( | ||
<Checkbox onChange={onChange} checked={accepted}> | ||
Accept terms and conditions? | ||
</Checkbox> | ||
); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.