diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..8bd344b --- /dev/null +++ b/package-lock.json @@ -0,0 +1,5 @@ +{ + "name": "react-native-pulse", + "version": "1.0.7", + "lockfileVersion": 1 +} diff --git a/pulse.js b/pulse.js index e89cb58..8d0d425 100644 --- a/pulse.js +++ b/pulse.js @@ -72,6 +72,53 @@ export default class Pulse extends Component { mounted = true; + static getDerivedStateFromProps(nextProps, prevState) { + if(nextProps.color != prevState.color){ + return { color: nextProps.color} + }; + if(nextProps.duration != prevState.duration) { + return { duration: nextProps.duration }; + }; + if(nextProps.maxDiameter != prevState.maxDiameter) { + return { maxDiameter: nextProps.maxDiameter }; + }; + if(nextProps.numPulses != prevState.numPulses) { + return { numPulses: nextProps.numPulses }; + }; + if(nextProps.speed != prevState.speed) { + return { speed:nextProps.speed }; + }; + } + +// componentWillReceiveProps(props) { +// if(props.color != this.state.color){ +// this.setState({ +// color: props.color +// }); +// }; +// if(props.duration != this.state.duration) { +// this.setState({ +// duration: props.duration +// }); +// }; +// if(props.maxDiameter != this.state.maxDiameter) { +// this.setState({ +// maxDiameter: props.maxDiameter +// }); +// }; +// if(props.numPulses != this.state.numPulses) { +// this.setState({ +// numPulses: props.numPulses +// }); +// }; +// if(props.speed != this.state.speed) { +// this.setState({ +// speed:props.speed +// }); +// }; + +// } + componentDidMount(){ const {numPulses, duration, speed} = this.state;