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?