R
R
Rapen2017-05-20 15:34:37
React
Rapen, 2017-05-20 15:34:37

Why does _this2.refs.push is not a function error occur in react?

there is a property in the class constructor - this.refs = [] array, why is the context lost?

<div className="listElem">
  37 |     		    {n}
  38 |              
> 39 | 	<input type="checkbox" ref={ (input) => {this.refs.push(input)}}/>
  40 | </div>
  41 |          )})
  42 |          }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
KnightForce, 2017-05-20
@Rapen

Because it is a built-in object that cannot be overridden, and the object does not have a push method.
Call it something else.)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question