Skip to content
This repository has been archived by the owner on Jun 16, 2023. It is now read-only.

Commit

Permalink
fix(rn-camera): use componentDidMount instead of `componentWillMoun…
Browse files Browse the repository at this point in the history
…t`. closes #1809 closes #1760
  • Loading branch information
n1ru4l committed Sep 24, 2018
1 parent 9f65f52 commit 2d311ff
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/RNCamera.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ export default class Camera extends React.Component<PropsType, StateType> {
super(props);
this._lastEvents = {};
this._lastEventsTimes = {};
this._isMounted = true;
this.state = {
isAuthorized: false,
isAuthorizationChecked: false,
Expand Down Expand Up @@ -288,7 +289,7 @@ export default class Camera extends React.Component<PropsType, StateType> {
} else if (typeof options.quality === 'string') {
options.quality = Camera.Constants.VideoQuality[options.quality];
}
if (typeof options.orientation=== 'string') {
if (typeof options.orientation === 'string') {
options.orientation = CameraManager.Orientation[options.orientation];
}
return await CameraManager.record(options, this._cameraHandle);
Expand Down Expand Up @@ -353,15 +354,21 @@ export default class Camera extends React.Component<PropsType, StateType> {
}
};

// eslint-disable-next-line
async componentWillMount() {
componentWillUnmount() {
this._isMounted = false;
}

async componentDidMount() {
const hasVideoAndAudio = this.props.captureAudio;
const isAuthorized = await requestPermissions(
hasVideoAndAudio,
CameraManager,
this.props.permissionDialogTitle,
this.props.permissionDialogMessage,
);
if (this._isMounted === false) {
return;
}
this.setState({ isAuthorized, isAuthorizationChecked: true });
}

Expand Down

0 comments on commit 2d311ff

Please sign in to comment.