在 (Accordion NativeBase) 中的 renderContent 或 renderHeader 中无法访问全局 this.state
global this.state is not accessible inside renderContent or renderHeader in (Accordion NativeBase)
问题描述
正如标题所说,全局 this.state 在 Accordion
中的 renderContent 或 renderHeader 中不可访问
renderContent(item)
{
console.log(this.state.anyVariable);
// Red page error => Cannot read property 'anyVariable' of undefined
}
预期行为
记录任意变量值
实际行为
它将 this.state 视为未定义!!
错误是否存在于 iOS 和 Android 中或其中任何一个?
我只在里面测试过IOS
使用箭头函数,
renderContent = item => {
{
console.log(this.state.anyVariable);
// Red page error => Cannot read property 'anyVariable' of undefined
}
或使用bind
.
问题描述
正如标题所说,全局 this.state 在 Accordion
中的 renderContent 或 renderHeader 中不可访问renderContent(item)
{
console.log(this.state.anyVariable);
// Red page error => Cannot read property 'anyVariable' of undefined
}
预期行为
记录任意变量值
实际行为
它将 this.state 视为未定义!!
错误是否存在于 iOS 和 Android 中或其中任何一个?
我只在里面测试过IOS
使用箭头函数,
renderContent = item => {
{
console.log(this.state.anyVariable);
// Red page error => Cannot read property 'anyVariable' of undefined
}
或使用bind
.