This is a typical react issue but I kinda don't know how to handle it. I just want to render my table lines dynamically but I get the error:" "Uncaught Error: Invariant Violation: processUpdates(): Unable to find child 2 of 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 .2.1.0
."
I understand react is not finding the right DOM stuff but how to handle that ? Thanks in advance !
<div className="panel-body" style={panelstyle}>
<Table striped bordered condensed hover>
<thread>
<th> Currency </th>
<th> Amount </th>
<th> Issuer </th>
<th> Limit </th>
<th> Limit Peer </th>
<th> No-Ripple </th>
</thread>
<tbody>
{this.state.ripplelines[this.address] ?
this.state.ripplelines[this.address].lines.map(function(line,i) {
return (<tr>
<td> USD </td>
<td> 1500 </td>
<td> raazdazdizrjazirazrkaẑrkazrâkrp </td>
<td> 1000000000 </td>
<td> 0 </td>
<td> True </td>
</tr>)
;
})
: ""}
</tbody>
</Table>
</div>
Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
createElement()Create and return a new React element of the given type. The type argument can be either a tag name string (such as 'div' or 'span' ), a React component type (a class or a function), or a React fragment type.
Virtual DOM is definitely the most important factor that contributes to React performance, but it's not the only one. React has self-contained components that can be easily integrated and reused across multiple projects. Consequently, you can drastically save development time.
There is an answer here: React js: Invariant Violation: processUpdates() when rendering a table with a different number of child rows
Just prepare your rows before rendering!
render:
var rows = [];
if(this.state.ripplelines[this.address] ) {
_.each(this.state.ripplelines[this.address].lines, function(line) {
rows.push( <tr>
<td> somestuff!</td>
</tr>)
});
}
return (
<Table striped bordered condensed hover>
<thead>
<th> Currency </th>
<th> Amount </th>
<th> Issuer </th>
<th> Limit </th>
<th> Limit Peer </th>
<th> No-Ripple </th>
</thead>
<tbody>
{rows}
</tbody>
</Table>
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With