- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
由于性能原因,我想直接更新组件的值。
render(){
<View>
<Text style={styles.welcome} ref={component => this._text = component}>
Some Text
</Text>
<TouchableHighlight underlayColor='#88D4F5'
style={styles.button}>
<View>
<Text style={styles.buttonText}
onPress={this.useNativePropsToUpdate.bind(this)}>
Iam the Child
</Text>
</View>
</TouchableHighlight>
</View>
}
useNativePropsToUpdate(){
this._text.setNativeProps({text: 'Updated using native props'});
}
this._text.props.children = "updated";
最佳答案
而不是尝试更改<Text>
组件的内容。我只是替换为<TextInput editable={false} defaultValue={this.state.initValue} />
,其余代码保持不变。如果有人知道如何使用<Text>
或其他直接操作方法来更改setNativeProps
的值。发布答案,并进行不良审查并接受。
关于react-native - setNativeProps更改文本组件的值React native 直接操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37016664/
有没有人想出一种在不触发渲染的情况下动态改变屏幕上文本的方法? 我的屏幕的很大一部分使用 setNativeProps 来移动部件,这意味着尽管使用了 shouldComponentUpdate,动画
我用过 react-native-drawer 。我将侧边菜单文件单独保存,并将其导入到主文件中。我想在侧面菜单文件中编写点击功能。当我单击第一个项目时,它给了我这个错误。 我怎么能解决这个问题我认为
我有一个带有 TextInput、Picker 和 TouchableHiglight 的表单。 用户将在 TextInput 中输入内容,从 Picker 中选择一个项目并使用 TouchableH
我想防止整个树的重新渲染,所以,我想在需要时使用 setNativeProps 来更新特定组件,但是 setNativeProps 不起作用对于所有组件。我在我的 React Native 应用程序中
我有以下Snack Expo: https://snack.expo.io/rJ4mAxhmV 然后,我尝试将 react-navigation 的版本更新为 3.0.9,结果如下: https://
我正在用 React Native 开发 UI,在此 与源一起使用,我想通过 setNativeProps 而不是通过状态更改图像源。 我的代码是: 在某些事件上我想改变它的来源: this.ref
我正在学习React Native。我试图理解代码 Here 。下面的代码片段对我来说似乎很奇怪。你能解释一下它的作用吗? circle: (null : ?{ setNativeProps(prop
我正在尝试将 React Native 的类组件转换为涉及 useRef 的功能组件。以下是类组件: import React, { Component } from "react"; import
我很难处理这个错误。 我不明白为什么?我有一个未使用自定义组件的子组件。我将 Text 或 Image 或 Icon 包装在 View 组件中,然后将它们包装在 TouchableHighlight
我是一名优秀的程序员,十分优秀!