Comments (1)
我自己写了一下,我这边不好测试
把
constructor(props) {
super(props);
this.state = {};
this.needsReSetup = false;
this._isMount = false;
this.instance = null;
}
修改
constructor(props) {
super(props);
this.state = {
needsReSetup: false
};
this._isMount = false;
this.instance = null;
}
把
componentWillReceiveProps(nextProps) {
let nextChildrenLength = (nextProps.children || []).length;
let prevChildrenLength = (this.props.children || []).length;
if (nextChildrenLength !== prevChildrenLength) {
this.needsReSetup = true;
}
}
修改为
// Check children length change and prepare for re-setup
static getDerivedStateFromProps(props, state) {
const nextChildrenLength = (props.children || []).length
const prevChildrenLength = (state.prevChildren || []).length
if(nextChildrenLength !== prevChildrenLength) {
return {
prevChildren: nextChildrenLength,
needsReSetup: true
}
}
return null;
}
把
componentDidUpdate() {
if (this._isMount && this.needsReSetup) {
this.setupSwipe();
this.needsReSetup = false;
}
}
修改为
componentDidUpdate() {
if (this._isMount && this.state.needsReSetup) {
this.setupSwipe();
this.setState({
needsReSetup: false
})
}
}
from swipe.
Related Issues (20)
- Zoom does not work HOT 1
- Add configurable selector for children to use as a slides HOT 1
- Recalculate widths without changing inline css transition duration HOT 9
- slide(index, duration) does not work HOT 2
- enhancement: add 3 missing props to React documentation HOT 2
- Each slide appears diagonally below the one before it HOT 5
- Question: Is there a way to make what is inside of swipe wrap also clickable? HOT 1
- method of judging amd may cause error:Cannot set property 'Swipe' of undefined
- Multiple Swipe instances? HOT 1
- Using {passive: true} may causes the problem of event conflict on Safari HOT 1
- overlapping slides HOT 2
- A few suggestions HOT 1
- Clicked ignored elements are prevented from default behavior
- Layout is broken if swipe widget is disabled
- Layout jump after init HOT 2
- Flex direction row-reverse not working? HOT 1
- continuous为true且children个数为两个时显示有问题 HOT 1
- Desktop weirdness... HOT 1
- slide function directions HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swipe.