Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

Calling Subcomponent using JSX throws error

$
0
0

I am trying to call one subcomponent within the same class but it throws an error If I use it with curly braces it's working fine.

Below code throws an error:

public TotalCostSavings = () => {        return <View />;    };    public Savings = () => {        return (<View><this.TotalCostSavings /></View>        );    };

Error: `

Element type is invalid: expected a string (for built-in components)or a class/function (for composite components) but got: undefined. Youlikely forgot to export your component from the file it's defined in,or you might have mixed up default and named imports`

The below code works fine:

public TotalCostSavings = () => {        return <View />;    };    public Savings = () => {        return (<View>                {this.TotalCostSavings()}</View>        );    };

Why the first approach is not working?


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>