diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 00000000..c45b70bf --- /dev/null +++ b/package-lock.json @@ -0,0 +1,5 @@ +{ + "name": "forked-react-native-sketch-canvas", + "version": "0.8.0", + "lockfileVersion": 1 +} diff --git a/src/SketchCanvas.js b/src/SketchCanvas.js index 8f4fe48f..b813eb35 100644 --- a/src/SketchCanvas.js +++ b/src/SketchCanvas.js @@ -90,12 +90,16 @@ class SketchCanvas extends React.Component { this._initialized = false this.state.text = this._processText(props.text ? props.text.map(t => Object.assign({}, t)) : null) + + this.createPanResponder(); } - componentWillReceiveProps(nextProps) { - this.setState({ - text: this._processText(nextProps.text ? nextProps.text.map(t => Object.assign({}, t)) : null) - }) + componentDidUpdate(prevProps) { + if (prevProps.text !== this.props.text) { + this.setState({ + text: this._processText(this.props.text ? this.props.text.map(t => Object.assign({}, t)) : null) + }) + } } _processText(text) { @@ -152,7 +156,7 @@ class SketchCanvas extends React.Component { } } - componentWillMount() { + createPanResponder() { this.panResponder = PanResponder.create({ // Ask to be the responder: onStartShouldSetPanResponder: (evt, gestureState) => true, @@ -218,6 +222,7 @@ class SketchCanvas extends React.Component { } async componentDidMount() { + if (this.props.saveToStorage === false) return; const isStoragePermissionAuthorized = await requestPermissions( this.props.permissionDialogTitle, this.props.permissionDialogMessage,