Repository navigation
React Native only supports JSX #144
Description
Activity
Can you try
var Text = React.createFactory(React.Text); return React.createElement(Text, 'Hello World');cc @balpert
Arggh .. ignore me, I'm being an idiot. This fails:
return React.createElement('Text', { style: styles.text }, 'Hello World!');Where
Textis passed as a string, but this works:return React.createElement(Text, { style: styles.text }, 'Hello World!');The error message is still really bad. Would be nice to throw an exception along the lines of 'You tried to render the element 'Text' but it doesn't exist. You can only use string notation for lowercase components'. Want to submit a pull request that warns against this? It would prevent other people from failing into the same mistake
We actually don't use or support string-typed components in React native at all. Would be nice to add a warning for non-lowercase components in React core though.
I agree, the error message isn't great. As the react-native behaviour differs from react in this case, one option is to adapt the
createElementfunction, and add the extra parameter type checking here:https://github.com/facebook/react-native/blob/master/Libraries/ReactIOS/ReactIOS.js#L32
What do you think?
In neither case do uppercase tag names make sense, so we can add a warning in React core. We might also want to add some sort of warning for using any string type in React Native.
- locked as resolved and limited conversation to collaborators
on May 29, 2018 - addedResolution: LockedThis issue was locked by the bot.This issue was locked by the bot.
on Jul 23, 2018
Unless I am mistake, I should be able to substitute this:
With this:
However, the above causes the application to fail as follows: