Advertisement
Guest User

Untitled

a guest
Jul 18th, 2017
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. class Criterias extends React.Component {
  2. constructor(props) {
  3. super(props);
  4. this.state = {critList: {}, checkState: {}};
  5. this.checkboxOnChange = this.checkboxOnChange.bind(this);
  6. }
  7. componentDidMount() {
  8. axios.get('...')
  9. .then((response) => {
  10. this.setState({critList : response.data})
  11. })
  12. .catch(function (error) {
  13. console.log(error);
  14. });
  15. }
  16. checkboxOnChange(){
  17. var key = event.target.id;
  18.  
  19. var tmpObj = this.state.checkState;
  20. var newValue = !this.state.checkState[event.target.id];
  21. console.log(newValue);
  22. tmpObj[key] = newValue;
  23. console.log(tmpObj);
  24. this.setState({checkState : tmpObj});
  25. console.log(tmpObj);
  26. }
  27.  
  28. ...
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement