React-d3 findComponentRoot(..., .0.0.1.0.0.1.0.$/=13.0.$faux-dom-0): 找不到元素
React-d3 findComponentRoot(..., .0.0.1.0.0.1.0.$/=13.0.$faux-dom-0): Unable to find element
我尝试使用对 react-d3
的反应,但我总是遇到错误,第一次,我使用 react v16
但它请求 React v0.14.9
。
所以现在我可以在错误出现之前看到图表。
我用过this tuto from react d3.
在那里设置后出现错误:
findComponentRoot(..., .0.0.1.0.0.1.0.$/=13.0.$faux-dom-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 ''.
听起来我有一个 table 但没有,App.js 看起来像:
import React, { Component } from 'react';
import './App.css';
import {Chart} from 'react-d3-core';
import {LineChart} from 'react-d3-basic';
class App extends Component {
render() {
var chartData = [
{data: 2000}
]
var width = 700,
height = 300,
margins = {left: 100, right: 100, top: 50, bottom: 50},
title = "User sample",
// chart series,
// field: is what field your data want to be selected
// name: the name of the field that display in legend
// color: what color is the line
chartSeries = [
{
field: 'BMI',
name: 'BMI',
color: '#ff7f0e'
}
],
// your x accessor
x = function(d) {
return d.index;
}
return (
<div className="App">
<Chart
title={title}
width={width}
height={height}
margins= {margins}
>
<LineChart
showXGrid= {false}
showYGrid= {false}
margins= {margins}
title={title}
data={chartData}
width={width}
height={height}
chartSeries={chartSeries}
x={x}
/>
</Chart>
</div>
);
}
}
export default App;
package.json
{
"name": "reactd3",
"version": "0.1.0",
"private": true,
"dependencies": {
"ajv": "^6.5.2",
"babel-loader": "^7.1.5",
"html-webpack-plugin": "^3.2.0",
"react": "^0.14.9",
"react-d3": "^0.4.0",
"react-d3-basic": "^1.6.11",
"react-dom": "^0.14.9",
"react-scripts": "1.1.4",
"style-loader": "^0.21.0",
"webpack": "^4.16.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"devDependencies": {
"webpack-cli": "^3.1.0"
}
}
没有理由出现该错误,因为图表没有 table 表格。
我尝试在它之前使用 react16 但没有成功,很多错误...
编辑:现在我们使用 d3.js
而不是 react-d3
并且它有效,但如果有人有那个问题可以解决它就更好了。
恕我直言,此错误与整个应用根目录(html 中的'root')无关,而是与其中一个子组件相关。
在反应渲染的早期版本中,DOM 节点由附加的 html 属性 'data-reactid' 标识,其值与虚拟节点路径相关。 '.0.0.1.0.0.1.0...' 就是一个例子。
这个错误意味着 React 在虚拟树中有这个节点,想要在 DOM 中更新它,但是由于某种原因 DOM 节点(之前用这个 id 渲染)消失了。也许浏览器 'corrected' 错误 html 结构?这可能与任何 html 错误有关,table 显示为示例原因。
有什么理由不从不维护 'react-d3' 切换到 'react-d3-components'?
我尝试使用对 react-d3
的反应,但我总是遇到错误,第一次,我使用 react v16
但它请求 React v0.14.9
。
所以现在我可以在错误出现之前看到图表。
我用过this tuto from react d3.
在那里设置后出现错误:
findComponentRoot(..., .0.0.1.0.0.1.0.$/=13.0.$faux-dom-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 ''.
听起来我有一个 table 但没有,App.js 看起来像:
import React, { Component } from 'react';
import './App.css';
import {Chart} from 'react-d3-core';
import {LineChart} from 'react-d3-basic';
class App extends Component {
render() {
var chartData = [
{data: 2000}
]
var width = 700,
height = 300,
margins = {left: 100, right: 100, top: 50, bottom: 50},
title = "User sample",
// chart series,
// field: is what field your data want to be selected
// name: the name of the field that display in legend
// color: what color is the line
chartSeries = [
{
field: 'BMI',
name: 'BMI',
color: '#ff7f0e'
}
],
// your x accessor
x = function(d) {
return d.index;
}
return (
<div className="App">
<Chart
title={title}
width={width}
height={height}
margins= {margins}
>
<LineChart
showXGrid= {false}
showYGrid= {false}
margins= {margins}
title={title}
data={chartData}
width={width}
height={height}
chartSeries={chartSeries}
x={x}
/>
</Chart>
</div>
);
}
}
export default App;
package.json
{
"name": "reactd3",
"version": "0.1.0",
"private": true,
"dependencies": {
"ajv": "^6.5.2",
"babel-loader": "^7.1.5",
"html-webpack-plugin": "^3.2.0",
"react": "^0.14.9",
"react-d3": "^0.4.0",
"react-d3-basic": "^1.6.11",
"react-dom": "^0.14.9",
"react-scripts": "1.1.4",
"style-loader": "^0.21.0",
"webpack": "^4.16.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"devDependencies": {
"webpack-cli": "^3.1.0"
}
}
没有理由出现该错误,因为图表没有 table 表格。
我尝试在它之前使用 react16 但没有成功,很多错误...
编辑:现在我们使用 d3.js
而不是 react-d3
并且它有效,但如果有人有那个问题可以解决它就更好了。
恕我直言,此错误与整个应用根目录(html 中的'root')无关,而是与其中一个子组件相关。
在反应渲染的早期版本中,DOM 节点由附加的 html 属性 'data-reactid' 标识,其值与虚拟节点路径相关。 '.0.0.1.0.0.1.0...' 就是一个例子。
这个错误意味着 React 在虚拟树中有这个节点,想要在 DOM 中更新它,但是由于某种原因 DOM 节点(之前用这个 id 渲染)消失了。也许浏览器 'corrected' 错误 html 结构?这可能与任何 html 错误有关,table 显示为示例原因。
有什么理由不从不维护 'react-d3' 切换到 'react-d3-components'?