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

unable to cast object of type 'rncamera.rctcamera viewmanager' to type 'reactnative.uimanager.iviewparentmanager' #2148

Closed
3 tasks done
GabrielPerezB opened this issue Mar 15, 2019 · 2 comments
Labels
Help Wanted stale There has been a lack of activity on this issue and it may be closed soon. windows

Comments

@GabrielPerezB
Copy link

GabrielPerezB commented Mar 15, 2019

Bug Report

To Do First

  • Did you try latest release?
  • Did you try master?
  • Did you look for existing matching issues?

Related Modules

Platforms

  • react-native-windows

Versions

  • Android:
  • iOS:
  • Windows: 0.57.0-rc.5
  • react-native-camera: 2.0.0
  • react-native:0.57.0
  • react:16.6.3

Description/Current Behaviour
unable to cast object of type 'rncamera.rctcamera viewmanager' to type 'reactnative.uimanager.iviewparentmanager' On windows debugging

Expected Behaviour

Steps to Reproduce

import React, { Component } from "react";
import {
  AppRegistry,
  StyleSheet,
  Text,
  TouchableOpacity,
  View,
  TouchableHighlight,
  Dimensions
} from "react-native";
import Camera from 'react-native-camera';

class ImagePicker extends Component {

  requestPermissions = async () => {
    if (Platform.OS === "android") {
      const result = await PermissionsAndroid.request(
        PermissionsAndroid.PERMISSIONS.CAMERA
      );
      return result === PermissionsAndroid.RESULTS.GRANTED || result === true;
    }
    return true;
  };

  takePicture = async () => {
    if (this.camera) {
      const options = { quality: 0.5, base64: true };
      const data = await this.camera.takePictureAsync(options);
      console.log(data.uri);
    }
  };

  onBarCodeRead = e => {
    console.log(`Barcode Found! Type: ${e.type}\nData: ${e.data}`);
  };

  componentDidMount = () => {
    ({  _,status }) => {
      if (status !== "PERMISSION_GRANTED") {
        this.requestPermissions();
      }
    };
  };

  render() {
    return (
      <View style={styles.container}>
        <Camera
          ref={ref => {
            this.camera = ref;
          }}
          onBarCodeRead={e => this.onBarCodeRead(e)}
          style={styles.preview}
        >
          <Text style={styles.capture} onPress={() => this.takePicture()}>
            [CAPTURE]
          </Text>
        </Camera>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    flexDirection: "column",
    backgroundColor: "black",
    marginTop: 20
  },
  preview: {
    flex: 1,
    justifyContent: "flex-end",
    alignItems: "center"
  },
  capture: {
    flex: 0,
    backgroundColor: "#fff",
    borderRadius: 5,
    padding: 15,
    paddingHorizontal: 20,
    alignSelf: "center",
    margin: 20
  }
});

export default ImagePicker;

Additionals

image

Love react-native-camera? Please consider supporting our collective: 👉 https://opencollective.com/react-native-camera/donate
Want this issue to be resolved faster? Please consider adding a bounty to it https://issuehunt.io/repos/33218414

@stale
Copy link

stale bot commented Aug 5, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You may also mark this issue as a "discussion" and i will leave this open.

@stale stale bot added the stale There has been a lack of activity on this issue and it may be closed soon. label Aug 5, 2019
@stale
Copy link

stale bot commented Aug 12, 2019

Closing this issue after a prolonged period of inactivity. Fell free to reopen this issue, if this still affecting you.

@stale stale bot closed this as completed Aug 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Help Wanted stale There has been a lack of activity on this issue and it may be closed soon. windows
Projects
None yet
Development

No branches or pull requests

3 participants