1

So I have a simple Checkbox component from the react toolbox library, when I click it, I can see the checkbox going from checked to unchecked, but in the console I see these errors everytime I click it:

Uncaught Error: findComponentRoot(..., .0.0.1.1.1:$ripple1.0): Unable to find element. This probably means the DOM was unexpectedly mutated (e.g., by the browser), usually due to forgetting a when using tables, nesting tags like ,

, or , or using non-SVG elements in an parent. Try inspecting the child nodes of the element with React ID ``. invariant.js:39

My component:

import React from "react";
import { Link } from "react-router";
import { ButtonToolbar, Button } from 'react-bootstrap';
import Checkbox from 'react-toolbox/lib/checkbox';

export default React.createClass({
  getInitialState: function() {
    return {
      consent: false
    };
  },
  handleChange: function(field, value) {
    console.log(this.state);
    console.log(field, value);
    this.setState({ [field]: value });
  },
  render() {
    return (
      <div>
        <h2>Just testing</h2>
        <Checkbox type='checkbox' name='consent' label="I have read and agree to the terms & conditions listed in the PDF in step 2." onChange={this.handleChange.bind(this, 'consent')} checked={this.state.consent} />
      </div>
    );
  }
});

In my console, I can see that the handleChange function is working:
Object {consent: false} page.js:14
consent true

When I used React Inspector in Chrome to inspect the CheckBox component, I noticed two weird things:

  • the checked property is NOT changing in the parent component (CheckBox) when I click the checkbox.
  • the checked property IS changing in the input element inside this CheckBox component.
  • the state object IS changing (again according to my first point, the CheckBox component is not obeying checked={this.state.consent}!)

For some reason this.setState is NOT working on the component. Any insight would be appreciated!

ykadaru
  • 1,108
  • 2
  • 16
  • 32
  • Why are you setting the state like this: ` this.setState({ [field]: value });` with [ ] ? Shouldn't be: `this.setState({ field: value });` – pmiranda May 03 '17 at 18:00
  • @pmirnd I'm following the example in the documentation http://react-toolbox.com/#/components/checkbox I'm not sure which one is the right way – ykadaru May 03 '17 at 18:01
  • 1
    `this.setState({ [field]: value })` is valid es6 syntax. Can be used to initialize objects with dynamic keys. – Sasang May 03 '17 at 18:08
  • @Sasang sweet okay. – ykadaru May 03 '17 at 19:27
  • what was the react-toolbox version? May be this is related to [this issue](https://stackoverflow.com/a/25027055/1398867) – Venugopal Jun 28 '17 at 17:43

0 Answers0