I'm struggling to make use of an object in react, I'm trying to access the key:value that is being returned (and I can successfully console.log).
All the examples I've tried result in either mapping each character or throwing an object child error and i'm at a loss.
componentDidMount() {
this.gun.on('auth', () => this.thing());
}
thing() {
this.gun.get('todos').map((value, key) => { console.log(key, value) }
);
}
handleChange = e => this.setState({ newTodo: e.target.value })
add = e => {
e.preventDefault()
this.gun.get('todos').set(this.state.newTodo)
this.setState({ newTodo: '' })
}
del = key => this.gun.get(key).put(null)
render() {
return <>
<Container>
<div>Gun</div>
<div>
<form onSubmit={this.add}>
<input value={this.state.newTodo} onChange={this.handleChange} />
<button>Add</button>
</form>
<br />
<ul>
{this.state.todos.map(todo => <li key={todo.key} onClick={_ => this.del(todo.key)}>{todo.val}</li>)}
</ul>
</div>
</Container></>
}
}