onPress TouchableOpacity内存不足,React本机

时间:2018-11-17 14:29:31

标签: reactjs react-native expo

我有一个组件,当满足某些条件时(根据组件状态),我会在其中显示按钮

{
      this.state.inputTag !== null && this.state.inputTagFocused ? (
        <TouchableOpacity 
          style = {{backgroundColor : Colors.primary, padding : 15, paddingBottom : 5, paddingTop : 5, borderRadius: 2}}
          onPress = {this.handleAddTags}
        >
          <Text style = {{fontFamily : Fonts.primary, color : Colors.white}}>Add</Text>
        </TouchableOpacity>
      ) : null
    }

使用TextInput组件,我正在像这样更新状态

<TextInput
  style = {{ borderBottomColor : Colors.grey, padding : 15, paddingLeft :0, paddingRight : 0, marginRight : 15}}
  onChange = {(text)=> this.setState({inputTag : text})}
  onFocus = {() => this.setState({inputTagFocused : true})}
  placeholderTextColor = {Colors.grey}
  ref = {(tags) => {this.tags = tags}}
  underlineColorAndroid = 'transparent'
  placeholder = 'Add Tags'
  returnKeyType = 'done'
  multiline = {false}
/>

除了按下添加按钮时,所有应用似乎都崩溃了,几分钟后,我收到了“内存不足”的错误消息。

是什么原因引起的问题?以及如何解决?

完整代码可在 here

中找到

1 个答案:

答案 0 :(得分:1)

尝试在console.log()中用+替换

相关问题