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

View File

@@ -49,8 +49,8 @@
"karma-webpack": "^1.7.0",
"mocha": "^2.5.3",
"node-libs-browser": "^0.5.3",
"react": "^15.1.0",
"react-addons-test-utils": "^15.1.0",
"react": "^15.2.0",
"react-addons-test-utils": "^15.2.0",
"webpack": "^1.13.1",
"webpack-dev-server": "^1.14.1"
},

View File

@@ -16,7 +16,11 @@ import View from '../View'
export default class ScrollViewBase extends Component {
static propTypes = {
...View.propTypes,
onMomentumScrollBegin: PropTypes.func,
onMomentumScrollEnd: PropTypes.func,
onScroll: PropTypes.func,
onScrollBeginDrag: PropTypes.func,
onScrollEndDrag: PropTypes.func,
onTouchMove: PropTypes.func,
onWheel: PropTypes.func,
scrollEnabled: PropTypes.bool,
@@ -30,12 +34,10 @@ export default class ScrollViewBase extends Component {
constructor(props) {
super(props)
this._debouncedOnScrollEnd = debounce(this._handleScrollEnd, 100)
this._handlePreventableScrollEvent = this._handlePreventableScrollEvent.bind(this)
this._handleScroll = this._handleScroll.bind(this)
this._state = { isScrolling: false }
}
_handlePreventableScrollEvent(handler) {
_handlePreventableScrollEvent = (handler) => {
return (e) => {
if (!this.props.scrollEnabled) {
e.preventDefault()
@@ -45,7 +47,7 @@ export default class ScrollViewBase extends Component {
}
}
_handleScroll(e) {
_handleScroll = (e) => {
const { scrollEventThrottle } = this.props
// A scroll happened, so the scroll bumps the debounce.
this._debouncedOnScrollEnd(e)
@@ -83,9 +85,14 @@ export default class ScrollViewBase extends Component {
}
render() {
const {
onMomentumScrollBegin, onMomentumScrollEnd, onScrollBeginDrag, onScrollEndDrag, scrollEnabled, scrollEventThrottle, // eslint-disable-line
...other
} = this.props
return (
<View
{...this.props}
{...other}
onScroll={this._handleScroll}
onTouchMove={this._handlePreventableScrollEvent(this.props.onTouchMove)}
onWheel={this._handlePreventableScrollEvent(this.props.onWheel)}

View File

@@ -121,16 +121,15 @@ const ScrollView = React.createClass({
},
render() {
const scrollViewStyle = [
styles.base,
this.props.horizontal && styles.baseHorizontal
]
const contentContainerStyle = [
styles.contentContainer,
this.props.horizontal && styles.contentContainerHorizontal,
this.props.contentContainerStyle
]
const {
contentContainerStyle,
horizontal,
keyboardDismissMode, // eslint-disable-line
onContentSizeChange,
onScroll, // eslint-disable-line
refreshControl,
...other
} = this.props
if (process.env.NODE_ENV !== 'production' && this.props.style) {
const style = StyleSheet.flatten(this.props.style)
@@ -143,7 +142,7 @@ const ScrollView = React.createClass({
}
let contentSizeChangeProps = {}
if (this.props.onContentSizeChange) {
if (onContentSizeChange) {
contentSizeChangeProps = {
onLayout: this._handleContentOnLayout
}
@@ -155,13 +154,21 @@ const ScrollView = React.createClass({
children={this.props.children}
collapsable={false}
ref={INNERVIEW}
style={contentContainerStyle}
style={[
styles.contentContainer,
horizontal && styles.contentContainerHorizontal,
contentContainerStyle
]}
/>
)
const props = {
...this.props,
style: [scrollViewStyle, this.props.style],
...other,
style: [
styles.base,
horizontal && styles.baseHorizontal,
this.props.style
],
onTouchStart: this.scrollResponderHandleTouchStart,
onTouchMove: this.scrollResponderHandleTouchMove,
onTouchEnd: this.scrollResponderHandleTouchEnd,
@@ -187,7 +194,6 @@ const ScrollView = React.createClass({
'ScrollViewClass must not be undefined'
)
var refreshControl = this.props.refreshControl
if (refreshControl) {
return React.cloneElement(
refreshControl,

View File

@@ -14,6 +14,7 @@ class View extends Component {
accessibilityRole: createReactDOMComponent.propTypes.accessibilityRole,
accessible: createReactDOMComponent.propTypes.accessible,
children: PropTypes.any,
collapsable: PropTypes.bool,
hitSlop: EdgeInsetsPropType,
onClick: PropTypes.func,
onClickCapture: PropTypes.func,
@@ -53,6 +54,7 @@ class View extends Component {
render() {
const {
collapsable, // eslint-disable-line
hitSlop, // eslint-disable-line
onLayout, // eslint-disable-line
pointerEvents,