Skip to content

Commit

Permalink
fix(rn-camera): use instead of . closes react-native-camera#1809 closes
Browse files Browse the repository at this point in the history
  • Loading branch information
n1ru4l committed Sep 24, 2018
1 parent 9f65f52 commit ba7817d
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 ba7817d

Please sign in to comment.