Reputation: 2205
I am getting error in React-Native
as:
Invariant violation: View config not found for name MyCustomComponent.
I did search for same error and found that component name's first character should be capitalised which is there in my case.
This is what I am trying to do:
I am trying to load a component using name instead of rendering it directly using <MyCustomComponent />
Here is my code:
<View style={{ backgroundColor: 'yellow' }} >
{React.createElement('MyCustomComponent', {}, null)}
</View>
What can be the issue here. Is there any other way I can load component using string.
Upvotes: 1
Views: 4135
Reputation: 22209
You need to pass an component
and not a string
to the method
Like
{React.createElement(MyCustomComponent, {}, null)}
and not
{React.createElement('MyCustomComponent', {}, null)}
String is only for tags
Upvotes: 3