Help with using Expo Camera in TypeScript


Hello all, sorry for my first post being a request, but I am having a really hard time currently using the expo camera documentation in my typescript based app. I am unaware how to properly set the Camera component ref prop, in order to use the function takePictureAsync. Any guidance would be very appreciated.

Currently, I have public camera!: CameraObject; set at the top of my screen component, and set up my Camera component like so:

<Camera style={{ flex: 1 }} type={this.state.type}
      // tslint:disable-next-line:no-any
      ref={(ref: any) => {
   = ref;
            // tslint:disable-next-line:no-console

This seems to work OK (as long as i use .bind(this) on my take picture button onPress function), but I would prefer to not have to specify :any for ref. What should ref be typed as? Pretty much anything else I put seems to trigger a type error in TSLint, and using the ref type as it is directly in the props did not work (as it seems to expect a void function, and not a CameraObject).


closed #2

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.