invariant.js:39 Uncaught Invariant Violation: findComponentRoot(..., .0.0.0.1.1.$12.0.2.0): Unable to find element. This probably means the DOM was unexpectedly mutated (e.g., by the browser), usually due to forgetting a <tbody> when using tables, nesting tags like <form>, <p>, or <a>, or using non-SVG elements in an <svg> parent. Try inspecting the child nodes of the element with React ID ``.

出现上面的错误何故?由于我们在更新React render内容的时候,未指定React ID(ref),React也不支持大家这样更新DOM的内容,提倡我们使用setState或者 forceupdate更新state里面的内容
http://facebook.github.io/react/docs/component-api.html#forceupdate

那我们仅需更新state里面的值就好,若是数组较小(100记录下或1000记录下,根据你项目大小来定),我们直接更新数组里某个值。

var items = this.state.items;
items[i].status = 'doing';
this.setState({
      items: items
 

有疑问或技术交流,扫描公众号一起讨论学习。

更多React在线学习访问:http://each.sinaapp.com/react/index.html

invariant.js:39 Uncaught Invariant Violation: findComponentRoot(..., .0.0.0.1.1.$12.0.2.0): Unable to find element. This probably means the DOM was unexpectedly mutated (e.g., by the browser), usual... setState() 是异步更新数据的 注意:使用该语法时,后面的 setState() 不要依赖于前面的 setState() 可以多次调用 setState() ,只会触发一次重新渲染 this.state = { count: 1 } this.setState({ count: this.state.count + 1 co...
写代码过程中,你会发现,如果直接使用push等方法改变state,按理来说,push会改变原数组,数组应该更新,但渲染出来的state并不会更改。 今天遇到的问题是:组件内对数组元素进行修改后数据有变化但是页面没重新渲染 话说这是因为组件没能够识别数组的变化,所以页面没有重新渲染 所以只要让组件感知到你发生了改变,就可以达到刷新的效果 这是由于js中,数组的赋值是引用传递的,array.push相当于直接更改了数组对应的内存块,但react内部用于对比的array的内存并没有更改...
问题描述:经常会看到这样一个问题,明明已经调用setState的方法了,但是state的值不改变,或者是数据改变了,但是没有重新渲染。找到了几个解决办法,记录一下。思路一、可能是setState(value)中的value值的引用地址与state的一样 就比如最常用遇到的,对象或者数组的更新操作可能失败(最常遇到) 可能是这样的:** […b]这是一个新的数组,然后扩展b数组的元素到新数组,引用地址已经不一样了 所以总结:善用…扩展运算符思路二、可能调用这个set方法的onClick点击事件,被父元素的