用一个基础类,让TextInput 继承这个基础类 ,判断是否是IOS系统,最后返回一个 TextInput
直接上代码:
import React, {Component} from 'react'; import {Platform, TextInput} from 'react-native'; export default class LLTextInput extends Component { shouldComponentUpdate (nextProps){ return Platform.OS !== 'ios' || (this.props.value === nextProps.value && (nextProps.defaultValue == undefined || nextProps.defaultValue == '' )) || (this.props.defaultValue === nextProps.defaultValue && (nextProps.value == undefined || nextProps.value == '' )); } render() { return <TextInput {...this.props} />; } };