react-native decorator
使用Decorator 首先要安装相应的Babel插件
npm install babel-plugin-transform-decorators-legacy --save,同时,需要在.babelrc中的plugins里做相应配置:
"plugins": [
"transform-class-properties",
"babel-plugin-transform-decorators-legacy"
]
在react-native中移除Decorator警告 jsconfig.json
{ "compilerOptions": { "experimentalDecorators": true, "allowJs": true }}点击空白处键盘隐藏(react-native)
const dismissKeyboard = require('dismissKeyboard')
export default (WrappedComponent) => class AutoHideKeyboard extends Component {
render() {
return (
<TouchableWithoutFeedback style={{flex:1}} onPress={dismissKeyboard}>
<View style={{flex:1}}>
<WrappedComponent {...this.props}/>
</View>
</TouchableWithoutFeedback>
)
}
}
生活本就不容易,当你生活容易时,肯定有人替你承担了你的那份不容易
浙公网安备 33010602011771号