Reputation: 544
Inside of my render method I am calling a method which performs some conditional logic, based on API response data. I'm unclear how to resolve this error, considering I am not removing anything from the DOM. Here is my method
import numeral from 'numeral';
import moment from 'moment';
class SearchResultsListItem extends React.Component {
constructor(props) {
this.isMaxQtyGreaterThanOneThousand=
::this.isMaxQtyGreaterThanOneThousand;
}
isMaxQtyGreaterThanOneThousand(qty){
if(!!qty){
if(qty%1000 === 0){
return (numeral(qty).divide(1000).format('0,000') + 'M');
}else{
return numeral(qty);
}
}else{ return "-";}
}
render() {
const x = this.props.dataItem;
return (
<div className={`${s['quantity-block']}`}>
{this.isMaxQtyGreaterThanOneThousand(x.MaxQuantity)}
</div>
)
}
I've looked at the following posted in order to resolve this error, but haven't had much luck finding anything specific to jsx or React:
Failed to execute 'removeChild' on 'Node': parameter 1 is not of type 'Node'
Upvotes: 1
Views: 1352
Reputation: 39202
The error is because in some cases you are returning a numeral
object instead of a text string from your helper method. This is confusing React.
You probably want
return numeral(qty).format('0,000');
instead of
return numeral(qty)
Upvotes: 1