mirror of
https://github.com/mmalmi/mmalmi.github.io.git
synced 2025-06-04 00:12:03 +00:00
.
This commit is contained in:
parent
ab0f6998ca
commit
7633ae4e39
@ -12,12 +12,17 @@ Fed up with writing a ton of Redux boilerplate just to make a form input editabl
|
||||
|
||||
There’s a better alternative: Gun.js. It makes state synchronization and persistence super easy:
|
||||
|
||||
```js
|
||||
```jsx
|
||||
// Initialize Gun with options that make sure the state is synced to localStorage only
|
||||
const State = new Gun({multicast: false, peers: [], localStorage: true, file: 'State.local'});
|
||||
const State = new Gun({
|
||||
localStorage: true,
|
||||
file: 'State.local',
|
||||
multicast: false,
|
||||
peers: []
|
||||
});
|
||||
|
||||
class CommentForm {
|
||||
componentDidMount {
|
||||
componentDidMount() {
|
||||
State.get('comment').on(comment => this.setState({comment}));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user