Skip to content

Commit

Permalink
fix preact / react@15, ref ant-design/ant-design-mobile#1839
Browse files Browse the repository at this point in the history
  • Loading branch information
warmhug committed Oct 19, 2017
1 parent d44e32f commit a871296
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rmc-pull-to-refresh",
"version": "1.0.0",
"version": "1.0.1",
"description": "React Mobile Pull To Refresh Component",
"keywords": [
"react",
Expand Down
16 changes: 8 additions & 8 deletions src/PullToRefresh.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class StaticRenderer extends React.Component<any, any> {
return nextProps.shouldUpdate;
}
render() {
return this.props.render();
return <div>{this.props.render()}</div>;
}
}

Expand All @@ -21,7 +21,7 @@ const DOWN = 'down';
const UP = 'up';
const INDICATOR = { activate: 'release', deactivate: 'pull', release: 'loading', finish: 'finish' };

export default class PullToRefresh extends React.PureComponent<PropsType, any> {
export default class PullToRefresh extends React.Component<PropsType, any> {
static defaultProps = {
prefixCls: 'rmc-pull-to-refresh',
getScrollContainer: () => undefined,
Expand All @@ -35,7 +35,6 @@ export default class PullToRefresh extends React.PureComponent<PropsType, any> {
state = {
currSt: '',
dragOnEdge: false,
shouldUpdateChildren: false,
};

containerRef: any;
Expand All @@ -46,10 +45,11 @@ export default class PullToRefresh extends React.PureComponent<PropsType, any> {
_lastScreenY: any;
_timer: any;

componentWillReceiveProps(nextProps: PropsType & { children: any }) {
this.setState({
shouldUpdateChildren: this.props.children !== nextProps.children,
});
shouldUpdateChildren = false;

shouldComponentUpdate(nextProps: any) {
this.shouldUpdateChildren = this.props.children !== nextProps.children;
return true;
}

componentDidUpdate(prevProps: any) {
Expand Down Expand Up @@ -211,7 +211,7 @@ export default class PullToRefresh extends React.PureComponent<PropsType, any> {
} = this.props;

const renderChildren = <StaticRenderer
shouldUpdate={this.state.shouldUpdateChildren} render={() => children} />;
shouldUpdate={this.shouldUpdateChildren} render={() => children} />;

const renderRefresh = (cls: string) => {
const cla = classNames(cls, !this.state.dragOnEdge && `${prefixCls}-transition`);
Expand Down

0 comments on commit a871296

Please sign in to comment.