Skip to content

Commit 1aece45

Browse files
author
guohui.deng
committed
使用prop-types检查属性
1 parent f8b7da4 commit 1aece45

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

index.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import {
1515
Text,
1616
} from 'react-native'
1717

18+
import PropTypes from 'prop-types';
19+
1820
export const DURATION = {
1921
LENGTH_LONG: 2000,
2022
LENGTH_SHORT: 500,
@@ -133,17 +135,17 @@ const styles = StyleSheet.create({
133135
});
134136

135137
Toast.propTypes = {
136-
style: View.propTypes.style,
137-
position: React.PropTypes.oneOf([
138+
style: PropTypes.any,
139+
position: PropTypes.oneOf([
138140
'top',
139141
'center',
140142
'bottom',
141143
]),
142-
textStyle: Text.propTypes.style,
143-
positionValue: React.PropTypes.number,
144-
fadeInDuration: React.PropTypes.number,
145-
fadeOutDuration: React.PropTypes.number,
146-
opacity: React.PropTypes.number
144+
textStyle: propTypes.any,
145+
positionValue: PropTypes.number,
146+
fadeInDuration: PropTypes.number,
147+
fadeOutDuration: PropTypes.number,
148+
opacity: PropTypes.number
147149
}
148150

149151
Toast.defaultProps = {

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
"bugs": {
2828
"url": "https://github.com/crazycodeboy/react-native-easy-toast/issues"
2929
},
30+
"dependencies": {
31+
"prop-types": "^15.6.0"
32+
},
3033
"peerDependencies": {
3134
"react-native": ">=0.20.0"
3235
},

0 commit comments

Comments
 (0)