admin管理员组

文章数量:1400087

I'm a second year IT student and I'm building a mobile student app that will have this feature where users (students) can upload a single pdf file. I have only spent 2 weeks with React Native.

So, I got this code (Body.tsx) and it doesn't work:

import { StyleSheet, View, Button } from "react-native";
import DocumentPicker from 'react-native-document-picker';
import React from "react";

function Body() {

  const pickDocument = async () => {
    try {
      const result = await DocumentPicker.pick({
        type: [DocumentPicker.types.pdf],
      });
      console.log(result);
    } catch (err) {
      if (DocumentPicker.isCancel(err)) {
        console.log('User canceled the picker');
      } else {
        throw err;
      }
    }
  };

  return (
    <View style={styles.container}>
      <Button title="Upload" onPress={pickDocument}/>
    </View>
  );
}

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

export default Body;

All I get is this error: enter image description here

"Server Error Cannot read properties of undefined (reading 'getEnforcing') Call Stack factory app/Body.tsx"

I use expo, I don't know why but that's what we were taught.

本文标签: