Recebi o seguinte erro quando criei o index.js pra somente exportar o header:
Error: Element type is invalid: expected a string( for built-in components) or a class/function (for composite components) but got: object. You likely forgot to export your component from the file it's defined in.
meu header ta assim:
import React, { Fragment } from 'react';
import { Text, View, Image } from "react-native";
import styles from "./styles.js"
const MyHeader = ({ nameUser }) => {
return (
<View style={styles.header}>
<Image
source={require("../../res/img/user.png")}
style={styles.imageUser}
/>
<Text>{nameUser}</Text>
</View>
);
}
export default MyHeader;
meu index.js:
export { default as Header } from './Header';
Tentei importar assim no App.js e gerou o erro que eu mencionei no inicio
import {MyHeader} from './src/components/Header';
Só dá certo quando tento importar assim:
import MyHeader from './src/components/Header/Header';
Mas acho que não seria o ideal