Resolve React@15.2.0 unknown props warnings

This commit is contained in:
Nicolas Gallagher
2016-07-10 18:32:02 -07:00
parent 77f72aa129
commit c9d68fe93e
4 changed files with 37 additions and 22 deletions
+2 -2
View File
@@ -49,8 +49,8 @@
"karma-webpack": "^1.7.0", "karma-webpack": "^1.7.0",
"mocha": "^2.5.3", "mocha": "^2.5.3",
"node-libs-browser": "^0.5.3", "node-libs-browser": "^0.5.3",
"react": "^15.1.0", "react": "^15.2.0",
"react-addons-test-utils": "^15.1.0", "react-addons-test-utils": "^15.2.0",
"webpack": "^1.13.1", "webpack": "^1.13.1",
"webpack-dev-server": "^1.14.1" "webpack-dev-server": "^1.14.1"
}, },
+12 -5
View File
@@ -16,7 +16,11 @@ import View from '../View'
export default class ScrollViewBase extends Component { export default class ScrollViewBase extends Component {
static propTypes = { static propTypes = {
...View.propTypes, ...View.propTypes,
onMomentumScrollBegin: PropTypes.func,
onMomentumScrollEnd: PropTypes.func,
onScroll: PropTypes.func, onScroll: PropTypes.func,
onScrollBeginDrag: PropTypes.func,
onScrollEndDrag: PropTypes.func,
onTouchMove: PropTypes.func, onTouchMove: PropTypes.func,
onWheel: PropTypes.func, onWheel: PropTypes.func,
scrollEnabled: PropTypes.bool, scrollEnabled: PropTypes.bool,
@@ -30,12 +34,10 @@ export default class ScrollViewBase extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
this._debouncedOnScrollEnd = debounce(this._handleScrollEnd, 100) this._debouncedOnScrollEnd = debounce(this._handleScrollEnd, 100)
this._handlePreventableScrollEvent = this._handlePreventableScrollEvent.bind(this)
this._handleScroll = this._handleScroll.bind(this)
this._state = { isScrolling: false } this._state = { isScrolling: false }
} }
_handlePreventableScrollEvent(handler) { _handlePreventableScrollEvent = (handler) => {
return (e) => { return (e) => {
if (!this.props.scrollEnabled) { if (!this.props.scrollEnabled) {
e.preventDefault() e.preventDefault()
@@ -45,7 +47,7 @@ export default class ScrollViewBase extends Component {
} }
} }
_handleScroll(e) { _handleScroll = (e) => {
const { scrollEventThrottle } = this.props const { scrollEventThrottle } = this.props
// A scroll happened, so the scroll bumps the debounce. // A scroll happened, so the scroll bumps the debounce.
this._debouncedOnScrollEnd(e) this._debouncedOnScrollEnd(e)
@@ -83,9 +85,14 @@ export default class ScrollViewBase extends Component {
} }
render() { render() {
const {
onMomentumScrollBegin, onMomentumScrollEnd, onScrollBeginDrag, onScrollEndDrag, scrollEnabled, scrollEventThrottle, // eslint-disable-line
...other
} = this.props
return ( return (
<View <View
{...this.props} {...other}
onScroll={this._handleScroll} onScroll={this._handleScroll}
onTouchMove={this._handlePreventableScrollEvent(this.props.onTouchMove)} onTouchMove={this._handlePreventableScrollEvent(this.props.onTouchMove)}
onWheel={this._handlePreventableScrollEvent(this.props.onWheel)} onWheel={this._handlePreventableScrollEvent(this.props.onWheel)}
+21 -15
View File
@@ -121,16 +121,15 @@ const ScrollView = React.createClass({
}, },
render() { render() {
const scrollViewStyle = [ const {
styles.base, contentContainerStyle,
this.props.horizontal && styles.baseHorizontal horizontal,
] keyboardDismissMode, // eslint-disable-line
onContentSizeChange,
const contentContainerStyle = [ onScroll, // eslint-disable-line
styles.contentContainer, refreshControl,
this.props.horizontal && styles.contentContainerHorizontal, ...other
this.props.contentContainerStyle } = this.props
]
if (process.env.NODE_ENV !== 'production' && this.props.style) { if (process.env.NODE_ENV !== 'production' && this.props.style) {
const style = StyleSheet.flatten(this.props.style) const style = StyleSheet.flatten(this.props.style)
@@ -143,7 +142,7 @@ const ScrollView = React.createClass({
} }
let contentSizeChangeProps = {} let contentSizeChangeProps = {}
if (this.props.onContentSizeChange) { if (onContentSizeChange) {
contentSizeChangeProps = { contentSizeChangeProps = {
onLayout: this._handleContentOnLayout onLayout: this._handleContentOnLayout
} }
@@ -155,13 +154,21 @@ const ScrollView = React.createClass({
children={this.props.children} children={this.props.children}
collapsable={false} collapsable={false}
ref={INNERVIEW} ref={INNERVIEW}
style={contentContainerStyle} style={[
styles.contentContainer,
horizontal && styles.contentContainerHorizontal,
contentContainerStyle
]}
/> />
) )
const props = { const props = {
...this.props, ...other,
style: [scrollViewStyle, this.props.style], style: [
styles.base,
horizontal && styles.baseHorizontal,
this.props.style
],
onTouchStart: this.scrollResponderHandleTouchStart, onTouchStart: this.scrollResponderHandleTouchStart,
onTouchMove: this.scrollResponderHandleTouchMove, onTouchMove: this.scrollResponderHandleTouchMove,
onTouchEnd: this.scrollResponderHandleTouchEnd, onTouchEnd: this.scrollResponderHandleTouchEnd,
@@ -187,7 +194,6 @@ const ScrollView = React.createClass({
'ScrollViewClass must not be undefined' 'ScrollViewClass must not be undefined'
) )
var refreshControl = this.props.refreshControl
if (refreshControl) { if (refreshControl) {
return React.cloneElement( return React.cloneElement(
refreshControl, refreshControl,
+2
View File
@@ -14,6 +14,7 @@ class View extends Component {
accessibilityRole: createReactDOMComponent.propTypes.accessibilityRole, accessibilityRole: createReactDOMComponent.propTypes.accessibilityRole,
accessible: createReactDOMComponent.propTypes.accessible, accessible: createReactDOMComponent.propTypes.accessible,
children: PropTypes.any, children: PropTypes.any,
collapsable: PropTypes.bool,
hitSlop: EdgeInsetsPropType, hitSlop: EdgeInsetsPropType,
onClick: PropTypes.func, onClick: PropTypes.func,
onClickCapture: PropTypes.func, onClickCapture: PropTypes.func,
@@ -53,6 +54,7 @@ class View extends Component {
render() { render() {
const { const {
collapsable, // eslint-disable-line
hitSlop, // eslint-disable-line hitSlop, // eslint-disable-line
onLayout, // eslint-disable-line onLayout, // eslint-disable-line
pointerEvents, pointerEvents,