skip to Main Content

can the component be renamed with an alias?

some why its undefined and cannot be used.

when i use original name then everything is fine

view/ClientPricelist.js file

    export default function ClientPricelist({navigation, route, order_product, product_select}) { return null; }

controller/ClientPricelist.js

import {ClientPricelist as ClientPricelistView} from '../view/ClientPricelist';

export default function Index(){

    console.log(<ClientPricelistView/>);//in console its <UNDEFINED/>
    return <ClientPricelistView/>;//throws error its not named component
}

package.json

"dependencies":

"@expo/config-plugins": "~7.2.2",

"@expo/prebuild-config": "~6.2.4",

"@react-native-async-storage/async-storage": "1.18.2",

"@react-native-community/datetimepicker": "7.2.0",

"@react-native-community/netinfo": "9.3.10",

"@react-navigation/native": "^6.1.6",

"@react-navigation/native-stack": "^6.9.12",

"@shopify/flash-list": "1.4.3",

"create-react-class": "^15.7.0",

"crypto-js": "^4.1.1",

"eas-cli": "^3.13.0",

"expo": "^49.0.0",

"expo-build-properties": "~0.8.3",

"expo-checkbox": "~2.4.0",

"expo-image-picker": "~14.3.2",

"expo-location": "~16.1.0",

"expo-secure-store": "~12.3.1",

"expo-status-bar": "~1.6.0",

"phpass": "^0.1.1",

"project-can-json": "^1.0.1",

"project-react-mvc": "^1.1.6",

"project-rest-client": "^1.1.0-beta",

"react": "18.2.0",

"react-native": "0.72.6",

"react-native-get-random-values": "~1.9.0",

"react-native-keyboard-aware-scroll-view": "^0.9.5",

"react-native-safe-area-context": "4.6.3",

"react-native-screens": "~3.22.0",

"react-native-uuid": "^2.0.1"

"devDependencies":
"@babel/core": "^7.20.0"

2

Answers


  1. Chosen as BEST ANSWER

    Nice, thnx, it worked like needed.


  2. default exports could not de-structured, use import default

    import default as ClientPricelistView from '../view/ClientPricelist';
    
    export default function Index(){
    
        console.log(<ClientPricelistView/>);
        return <ClientPricelistView/>; component
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search