Skip to content

Commit

Permalink
- fixed componentWill* warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
alexnaiman committed Oct 3, 2019
1 parent 976cb23 commit 5b0aa36
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 22 deletions.
21 changes: 9 additions & 12 deletions DoubleTapView.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,15 @@ export default class DoubleTapView extends Component {
constructor() {
super();

this.gestureHandlers = {};
this.gestureHandlers = PanResponder.create({
onStartShouldSetPanResponder: (evt, gestureState) => (gestureState.numberActiveTouches === 1),
onStartShouldSetResponderCapture: (evt, gestureState) => (gestureState.numberActiveTouches === 1),
onMoveShouldSetPanResponder: (evt, gestureState) => (false),
onMoveShouldSetResponderCapture: (evt, gestureState) => (false),
onPanResponderTerminationRequest: (evt, gestureState) => false,
onPanResponderRelease: this.handlePanResponderRelease,

});

this.prevTouchInfo = {
prevTouchX: 0,
Expand All @@ -49,17 +57,6 @@ export default class DoubleTapView extends Component {

}

componentWillMount() {
this.gestureHandlers = PanResponder.create({
onStartShouldSetPanResponder: (evt, gestureState) => (gestureState.numberActiveTouches === 1),
onStartShouldSetResponderCapture: (evt, gestureState) => (gestureState.numberActiveTouches === 1),
onMoveShouldSetPanResponder: (evt, gestureState) => (false),
onMoveShouldSetResponderCapture: (evt, gestureState) => (false),
onPanResponderTerminationRequest: (evt, gestureState) => false,
onPanResponderRelease: this.handlePanResponderRelease,

});
}

distance = (x0, y0, x1, y1) => {
return Math.sqrt(Math.pow((x1 - x0), 2) + Math.pow((y1 - y0), 2)).toFixed(1);
Expand Down
10 changes: 5 additions & 5 deletions PdfView.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,18 @@ export default class PdfView extends Component {
}, 200);
}

componentWillReceiveProps(nextProps) {
componentDidUpdate(prevProps) {

if (nextProps.scale !== this.state.scale) {
if (this.props.scale !== this.state.scale) {
this._onScaleChanged({
scale: nextProps.scale / this.state.scale,
scale: this.props.scale / this.state.scale,
pageX: this.state.contentContainerSize.width / 2,
pageY: this.state.contentContainerSize.height / 2
});
}

if (nextProps.horizontal !== this.props.horizontal || nextProps.page !== this.props.page) {
let page = (nextProps.page) < 1 ? 1 : nextProps.page;
if (this.props.horizontal !== prevProps.horizontal || this.props.page !== prevProps.page) {
let page = (this.props.page) < 1 ? 1 : this.props.page;
page = page > this.state.numberOfPages ? this.state.numberOfPages : page;

if (this._flatList) {
Expand Down
10 changes: 5 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,20 +111,20 @@ export default class Pdf extends Component {

}

componentWillReceiveProps(nextProps) {
componentDidUpdate(prevProps) {

const nextSource = resolveAssetSource(nextProps.source);
const curSource = resolveAssetSource(this.props.source);
const nextSource = resolveAssetSource(this.props.source);
const curSource = resolveAssetSource(prevProps.source);

if ((nextSource.uri !== curSource.uri)) {
// if has download task, then cancel it.
if (this.lastRNBFTask) {
this.lastRNBFTask.cancel(err => {
this._loadFromSource(nextProps.source);
this._loadFromSource(this.props.source);
});
this.lastRNBFTask = null;
} else {
this._loadFromSource(nextProps.source);
this._loadFromSource(this.props.source);
}
}
}
Expand Down

0 comments on commit 5b0aa36

Please sign in to comment.