Component Exception Element type is invalid in react native

In My React Native App.js I have the following code

import { StatusBar } from 'expo-status-bar';
import React, { useRef, Component } from 'react';
import { StyleSheet, Text, View, Canvas } from 'react-native';
import { RNCamera } from "react-native-camera";
import * as tf from '@tensorflow/tfjs';
import * as handpose from '@tensorflow-models/handpose';

export default function App() {
  const webcamRef = useRef(null);
  const canvasRef = useRef(null);
  return (
    <View style={styles.container}>
      <RNCamera ref={webcamRef}
        style={{
          position: 'absolute',
          marginLeft: 'auto',
          marginRight: 'auto',
          left: 0,
          right: 0,
          textAlign: 'center',
          zIndex: 9,
          height: 480,
          width: 640
        }}
      />
      <Canvas ref={canvasRef}
        style={{
          position: 'absolute',
          marginLeft: 'auto',
          marginRight: 'auto',
          left: 0,
          right: 0,
          textAlign: 'center',
          zIndex: 9,
          height: 480,
          width: 640
        }}
      />
      <StatusBar style="auto" />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
});

The Code Above Says:

Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it’s defined in, or you might have mixed up default and named imports

Answer

I don’t think there’s a Canvas component from react-native. You are trying to import something that is not there in the actual react-native framework.

remove import Canvas from react-native.

To implement canvas, you can use this plugin instead https://www.npmjs.com/package/react-native-canvas