ฉันได้รับข้อผิดพลาดนี้หลังจากเรียกใช้แอพของฉัน:
ข้อผิดพลาด: การรวมกลุ่มล้มเหลว: ข้อผิดพลาด: ไม่สามารถแก้ไขโมดูลได้react-native-safe-area-contextจากnode_modules/react-navigation-stack/lib/module/vendor/views/Stack/StackView.js: ไม่พบการตอบสนองภายในพื้นที่ปลอดภัยบริบทภายในโครงการ
แต่สิ่งเดียวกันกับที่ฉันได้ทำเพื่อการสาธิตเก่าของฉัน มันทำงานได้ดีอย่างสมบูรณ์
ฉันไม่รู้ว่าฉันทำอะไรผิดที่นี่ กรุณาตรวจสอบรหัสของฉัน:
สำหรับการติดตั้ง:
- ตอบสนองเนทิฟนำทางและตัวจัดการท่าทาง:
npm install --save react-navigation
npm install --save react-native-gesture-handler
- ตอบโต้ Native Stack:
npm install --save react-navigation-stack
App.js
import { createAppContainer } from "react-navigation";
import { createStackNavigator } from "react-navigation-stack";
import FirstOptionsPage from "./FirstOptionsPage";
const MainNavigator = createStackNavigator(
  {
    FirstOptions: FirstOptionsPage
  },
  {
    defaultNavigationOptions: {
      headerStyle: {
        // backgroundColor: '#28F1A6',
        elevation: 0,
        shadowOpacity: 0
      },
      headerTintColor: "#ca375e",
      headerTitleStyle: {
        fontWeight: "bold",
        color: "#161616"
      }
    }
  }
);
const App = createAppContainer(MainNavigator); // For setting Navigation Stack
export default App;
และFirstOptionsPage.js:
import React from "react";
import {
  SafeAreaView,
  StyleSheet,
  View,
  Text,
  ScrollView,
  Switch
} from "react-native";
export default class FirstOptionsPage extends React.Component {
  static navigationOptions = {
    title: "Preferences"
  };
  constructor(props) {
    super(props);
    this.state = {
      switch1Value: false
    };
  }
  toggleSwitch1 = value => {
    this.setState({ switch1Value: value });
    console.log("Switch 1 is: " + value);
  };
  render() {
    const { navigate } = this.props.navigation;
    return (
      <SafeAreaView style={styles.mainContainerStyle}>
        <View style={styles.subContainerStyle}>
          <Text style={styles.subtitleTextStyle}>Someone likes my post</Text>
          <View style={styles.switchStyle}>
            <Switch
              onValueChange={this.toggleSwitch1}
              value={this.state.switch1Value}
              thumbColor={MAGENTA_COLOR_CODE}
              trackColor={{
                false: GREY_COLOR_CODE,
                true: DARK_GREY_COLOR_CODE
              }}
            />
          </View>
        </View>
      </SafeAreaView>
    );
  }
}
ฉันใหม่สำหรับ React-Native โปรดช่วยฉันแก้ไขด้วย
react-native-safe-area-contextในโมดูลโหนดของคุณreact-navigation-stackต้องการสิ่งนั้น แต่โมดูลโหนดของคุณไม่มี