App.js से मॉड्यूल को हल करने में असमर्थ - प्रतिक्रियाशील मूल

Nov 26 2020

मैं प्रतिक्रिया करने के लिए शांत हूं और मुझे पता है कि यह कुछ बेवकूफी है लेकिन मैं वास्तव में इसे देख नहीं सकता हूं।

मुझे निम्नलिखित त्रुटि मिलती है: "App.js" से "./app/compenders/Apptext" हल करने में असमर्थ

import React, { Component } from 'react';
import { Text,StyleSheet,Platform } from 'react-native';

function AppText ({children})
{
return <Text style = {styles.text}>{children}</Text>
}



const styles = StyleSheet.create({

text:{
    color:"tomato",
   

    ...Platform.select({
        ios:{
            fontSize:20,
            fontFamily:"Avenir"
        },
        android:{
            fontSize:18,
            fontFamily:"Roboto"
        }
    })
},

})
export default AppText;

ऊपर मेरी AppText स्क्रिप्ट है

यह app.js है

import { StatusBar } from 'expo-status-bar';
import React, { Fragment } from 'react';
import {Dimensions ,SafeAreaView, StyleSheet,TouchableWithoutFeedback,Alert, Text, View ,Image, Button,Platform, BackHandler} from 'react-native';
import{ useDimensions,useDeviceOrientation } from '@react-native-community/hooks';
import WelcomeScreen from './app/screens/WelcomeScreen';
import AppText from './app/components/Apptext';


export default function App() {
  return (
<View style ={{flex:1,justifyContent:"center",alignItems:"center",}}>
      <AppText>I like react</AppText>
    </View>
    
    
    );
}

जवाब

MuralishankarSundaram Nov 26 2020 at 11:10

कृपया app.js फ़ाइल / से फ़ोल्डर क्रम की जाँच करें

NoamanKhalil Nov 27 2020 at 22:15

पता नहीं क्यों, लेकिन प्रतिक्रिया में एक समस्या थी कि मैंने इस स्क्रिप्ट को कैसे निहित किया, मैंने इसे नीचे दिए गए तरीके से बदल दिया और यह ठीक काम कर रहा है।

import React from "react";
import { Text, StyleSheet, Platform } from "react-native";

function AppText({ children, style }) {
  return <Text style={[styles.text, style]}>{children}</Text>;
}

const styles = StyleSheet.create({
  text: {
    fontSize: 18,
    fontFamily: Platform.OS === "android" ? "Roboto" : "Avenir",
  },
});

export default AppText;