mirror of
https://github.com/mmalmi/mmalmi.github.io.git
synced 2025-06-05 17:02:03 +00:00
.
This commit is contained in:
parent
5131e08084
commit
a148266dc1
@ -14,7 +14,7 @@ Fed up with writing a ton of Redux boilerplate just to handle form input changes
|
|||||||
|
|
||||||
There’s a better alternative: [Gun.js](https://github.com/amark/gun). It makes state synchronization and persistence a breeze.
|
There’s a better alternative: [Gun.js](https://github.com/amark/gun). It makes state synchronization and persistence a breeze.
|
||||||
|
|
||||||
First, initialize Gun with options that make sure the state is synced with localStorage only (not with peers).
|
First, initialize Gun with options that ensure the state is synced with localStorage only (not with peers).
|
||||||
```jsx
|
```jsx
|
||||||
const State = new Gun({
|
const State = new Gun({
|
||||||
localStorage: true,
|
localStorage: true,
|
||||||
@ -51,7 +51,7 @@ class TextInput extends React.Component {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Now you have a text form that syncs its content across component instances and persists it in localStorage.
|
Now you have a text input that syncs its content across component instances and persists it in localStorage.
|
||||||
|
|
||||||
See the working example on [Codepen](https://codepen.io/mmalmi/pen/VwWVdKG).
|
See the working example on [Codepen](https://codepen.io/mmalmi/pen/VwWVdKG).
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user