You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
JSX is actually separate from React; JSX is a language extension to ECMAScript, whereas React is a UI API. JSX provides a JSXAttribute node, which is commonly compiled to one "prop" in a React API call.
This distinction dictates how concerns should be separated between a plugin providing JSX support and one providing React support. This plugin would need to make it possible to obtain completions for a JSXAttribute name, and possibly a JSXAttribute value. A plugin like tern-react would then provide the list of PropTypes, and maybe potential values and types, based on the React API's offerings.
(I should note that, ideally, tern-react would only provide React-related functionality. But actually, right now, tern-react also offers JSX support. I've talked with the author about separating the concerns of our plugins, but it doesn't seem like he's gotten around to it yet.)
This issue might be effectively gated by lack of loose parsing support, see #1. In the case for PropType names, because JSX supports "boolean attributes," we could offer completion in the following case, because the syntax tree is still valid:
Desired completion is "babyBoo".
Text is <Foo b></Foo>, cursor is after "b".
But in the following cases, the syntax tree is invalid, so completion is less likely to work:
Text is <Foo b=></Foo>, cursor is after "b". (We want to complete the JSXAttribute name.)
Text is <Foo babyBoo=></Foo>, cursor is after "=". (We want to complete the JSXAttribute value.)
Thankfully, the first case seems like the most important one, so we could probably get by well without loose parsing.
I tried a simple example and it didn't seem to work.
It would be really nice if this had basic support for completion of proptype names...
The text was updated successfully, but these errors were encountered: