From 5d1679d00a1caaf7c6ebe0393b90e08add772e5b Mon Sep 17 00:00:00 2001 From: John Williamson Date: Sun, 26 Nov 2017 13:11:13 +1000 Subject: [PATCH] fixed spacing --- examples/react/src/Todos.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/examples/react/src/Todos.js b/examples/react/src/Todos.js index f9b18b88..1a2bf004 100644 --- a/examples/react/src/Todos.js +++ b/examples/react/src/Todos.js @@ -1,6 +1,6 @@ -import './style.css' import React, { Component } from 'react' import Gun from 'gun' +import './style.css' const formatTodos = todos => Object.keys(todos) .map(key => ({ key, val: todos[key] })) @@ -12,23 +12,28 @@ export default class Todos extends Component { this.gun = gun.get('todos'); this.state = {newTodo: '', todos: []} } + componentWillMount() { this.gun.on(todos => this.setState({ todos: formatTodos(todos) })) } + add = e => { e.preventDefault() this.gun.path(Gun.text.random()).put(this.state.newTodo) this.setState({newTodo: ''}) } + del = key => this.gun.path(key).put(null) + handleChange = e => this.setState({ newTodo: e.target.value}) + render() { return
- - + +

} + }