我正在尝试开发一个react-native应用程序,以设计一个自定义主题组件,并使用将该屏幕包含在主题中this.props.child。问题是屏幕上的输入字段失去焦点,并且在键入每个字符后键盘都被关闭,因为onChange我正在更新状态变量,这可能会重新呈现整个主题。
我已经尝试过在Github上提供许多解决方案,例如将唯一键传递给输入字段,但是它们不起作用。
这是我的主题组件的样子:
import Header from './header'
import footer from './footer'
export default class Theme extends Component {
render() {
//------this is my header component----
<Header/>
<View>
//------this is my Body in which i include my sceen content----
{this.props.children}
</View>
//------this is my footer component----
<footer/>
}
}
Run Code Online (Sandbox Code Playgroud)
这是带有输入字段的屏幕:
import Theme from "../../components/Theme";
import { Input, Button } from "react-native-elements";
export default class ChangePassword extends Component {
constructor(props) {
super(props);
this.state = {
inputs:{
old_password : …Run Code Online (Sandbox Code Playgroud)