为什么我的控制台中没有定义记录?它也不会打印任何值
this.props.records.forEach(function(record){
numbers.push(
<tr key={record.id} >
<td>{record.title}</td>
</tr>)
})
控制台错误
Uncaught ReferenceError: record is not definedReact.createClass.onChange @ Inline JSX script:137React.createClass.changeHandler @ Inline JSX script:82ReactClass.createClass._handleChange @ react-with-addons.js:9067executeDispatch @ react-with-addons.js:3307forEachEventDispatch @ react-with-addons.js:3295executeDispatchesInOrder @ react-with-addons.js:3316executeDispatchesAndRelease @ react-with-addons.js:2689forEachAccumulated @ react-with-addons.js:19368EventPluginHub.processEventQueue @ react-with-addons.js:2896runEventQueueInBatch @ react-with-addons.js:11161ReactEventEmitterMixin.handleTopLevel @ react-with-addons.js:11187handleTopLevelImpl @ react-with-addons.js:11273Mixin.perform @ react-with-addons.js:18340ReactDefaultBatchingStrategy.batchedUpdates @ react-with-addons.js:9613batchedUpdates @ react-with-addons.js:16573ReactEventListener.dispatchEvent @ react-with-addons.js:11367
答案 0 :(得分:0)
您的数组可能包含一些undefined
值(例如[{id: 1}, undefined, {id: 2}]
)。
console.log(this.props.records);
// or set a debugger statement to inspect the state