Skip to content

Commit 063f255

Browse files
committed
chore(package): add yarn's lockfile
1 parent 2ad3568 commit 063f255

File tree

4 files changed

+1312
-1
lines changed

4 files changed

+1312
-1
lines changed

.DS_Store

6 KB
Binary file not shown.

index.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, { Component, PropTypes } from 'react';
22
import { ScrollView, Animated, Platform, Easing } from 'react-native';
3+
import shallowCompare from 'react-addons-shallow-compare';
34

45
export default class Carousel extends Component {
56

@@ -27,6 +28,11 @@ export default class Carousel extends Component {
2728
* Style of each item's container
2829
*/
2930
slideStyle: PropTypes.number.isRequired,
31+
/**
32+
* whether to implement a `shouldComponentUpdate`
33+
* strategy to minimize updates
34+
*/
35+
shouldOptimizeUpdates: PropTypes.bool,
3036
/**
3137
* Global wrapper's style
3238
*/
@@ -91,6 +97,7 @@ export default class Carousel extends Component {
9197
};
9298

9399
static defaultProps = {
100+
shouldOptimizeUpdates: true,
94101
autoplay: false,
95102
autoplayInterval: 3000,
96103
autoplayDelay: 5000,
@@ -136,6 +143,14 @@ export default class Carousel extends Component {
136143
}
137144
}
138145

146+
shouldComponentUpdate(nextProps, nextState) {
147+
if (this.props.shouldOptimizeUpdates === false) {
148+
return true;
149+
} else {
150+
return shallowCompare(this, nextProps, nextState);
151+
}
152+
}
153+
139154
componentWillUnmount () {
140155
this.stopAutoplay();
141156
}

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@
2323
],
2424
"author": "Archriss",
2525
"license": "ISC",
26+
"dependencies": {
27+
"react-addons-shallow-compare": "latest"
28+
},
2629
"devDependencies": {
27-
"react-addons-shallow-compare": "latest",
2830
"babel-eslint": "^6.1.2",
2931
"babel-preset-react-native": "^1.9.0",
3032
"eslint": "^3.6.1",

0 commit comments

Comments
 (0)