在 react-native-paper 中使用 TextInputMask 在 TextInput 上获取错误
Getting Error on TextInput with TextInputMask in react-native-paper
警告:componentWillReceiveProps 已重命名,不建议使用。看
react-unsafe-component-lifecycles 了解详情。
- 将数据获取代码或副作用移至 componentDidUpdate。
- 如果您在 props 更改时更新状态,请重构您的代码以使用记忆技术或将其移至静态 getDerivedStateFromProps。了解更多信息:react-derived-state
- 将 componentWillReceiveProps 重命名为 UNSAFE_componentWillReceiveProps 以在非严格模式下抑制此警告。在 React 17.x 中,只有 UNSAFE_ 名称有效。要将所有已弃用的生命周期重命名为新名称,您可以在项目源文件夹中 运行
npx react-codemod rename-unsafe-lifecycles
。
请更新以下组件:TextInputMask
<TextInput
mode="outlined"
label="Pincode"
value={this.state.pincode}
onChangeText={this.handlePincodeChange}
left={<TextInput.Icon style={{marginEnd:10}} color='#156da9' name="map-marker"/>}
style={styles.textInput}
keyboardType='number-pad'
render={props =>
<TextInputMask
{...props}
mask="[000000]"
/>
}
theme={theme}
/>
警告:componentWillReceiveProps 已重命名,不建议使用。看 react-unsafe-component-lifecycles 了解详情。
- 将数据获取代码或副作用移至 componentDidUpdate。
- 如果您在 props 更改时更新状态,请重构您的代码以使用记忆技术或将其移至静态 getDerivedStateFromProps。了解更多信息:react-derived-state
- 将 componentWillReceiveProps 重命名为 UNSAFE_componentWillReceiveProps 以在非严格模式下抑制此警告。在 React 17.x 中,只有 UNSAFE_ 名称有效。要将所有已弃用的生命周期重命名为新名称,您可以在项目源文件夹中 运行
npx react-codemod rename-unsafe-lifecycles
。
请更新以下组件:TextInputMask
<TextInput
mode="outlined"
label="Pincode"
value={this.state.pincode}
onChangeText={this.handlePincodeChange}
left={<TextInput.Icon style={{marginEnd:10}} color='#156da9' name="map-marker"/>}
style={styles.textInput}
keyboardType='number-pad'
render={props =>
<TextInputMask
{...props}
mask="[000000]"
/>
}
theme={theme}
/>