Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Criterias extends React.Component {
- constructor(props) {
- super(props);
- this.state = {critList: {}, checkState: {}};
- this.checkboxOnChange = this.checkboxOnChange.bind(this);
- }
- componentDidMount() {
- axios.get('...')
- .then((response) => {
- this.setState({critList : response.data})
- })
- .catch(function (error) {
- console.log(error);
- });
- }
- checkboxOnChange(){
- var key = event.target.id;
- var tmpObj = this.state.checkState;
- var newValue = !this.state.checkState[event.target.id];
- console.log(newValue);
- tmpObj[key] = newValue;
- console.log(tmpObj);
- this.setState({checkState : tmpObj});
- console.log(tmpObj);
- }
- ...
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement