Skip to content

Instantly share code, notes, and snippets.

@du5rte
Created June 30, 2017 12:02
Show Gist options
  • Save du5rte/5e2586be70c72007fefb174cbb64820d to your computer and use it in GitHub Desktop.
Save du5rte/5e2586be70c72007fefb174cbb64820d to your computer and use it in GitHub Desktop.
import React, { Component } from "react";
import _ from "lodash";
export default class Example extends Component {
constructor(props) {
super(props);
this.state = {
uid: "",
displayname: "",
currency: {
uid: "coins",
displayname: "Coins",
rate: 1,
precision: 0
}
};
}
handleChange(e) {
const { name, value } = e.target;
const newState = _.set(this.state, name, value);
this.setState(newState);
}
render() {
return (
<View>
<input
type="text"
name="currency.uid"
value={_.get(this.state, "currency.uid")}
onChange={this.handleChange.bind(this)}
/>
</View>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment