Это мое условие If else. Независимо от того, какое имя класса является его рендерингом в той же форме, я получаю эту проблему, я хочу решить эту проблему.
const square = "nodesquare";
var form;
if (square) {
form = <form>
<input className = "process" type = "text" name = "process" id = "process" />
<Button type = "primary" className = "button center" onClick = {this.clearAll}>Add</Button>
</form>
console.info('Form')
} else {
form = <p>Nothing to Watch</p>
}
return (
<div
key = {index}
className = {'node ' + node.className}
id = {node.id}
ref = {nodes => this.refs.nodes[index] = nodes}
style = {node.style}
onClick = {this.activeElem}
square = {square}>
{form}
<div className = "delete-btn" onClick = {event => this.deleteNode(event, node)}>X</div>
</div>
)
})}
</div >
);





Я не уверен, что понимаю, в чем ваша проблема.
Поскольку ваш square const всегда равен "nodesquare", ваш код всегда будет запускать условие if и никогда другое.
Ты говоришь:
const square = "nodesquare";
var form;
if (square) { ....
Похоже, squareвсегда truthy. Проверьте концепции правдиво и ложно в javascript.
Основная проблема, с которой я столкнулся, заключается в том, что я был на площади привязки Div, поэтому я получаю эту ошибку, посмотрите здесь.
key = {index}
className = {'node ' + node.className}
id = {node.id}
ref = {nodes => this.refs.nodes[index] = nodes}
style = {node.style}
onClick = {this.activeElem}
square = {square}
>
thats why it was always true thanks for your Precious Time