2 ms·
Firstly, you're right that the main content of the post is re: not needing to import React. My comment was just pointing out that they have additionally changed
by lucideer 6y ago
Firstly, you're right that the main content of the post is re: not needing to import React. My comment was just pointing out that they have additionally changed the factory signature (an unrelated change).
Secondly, I should point out that JSX is currently not dependent on React. You can use JSX now without React, either via Typescript (built-in support) or via the custom `pragma` config key in babel's JSX plugin.
The change described in the article makes it unnecessary to import the full React lib into each component file when using JSX with React.
I'm not sure what the benefit of this is tbh...
- henryfjordan 6y agoYou'll be able to tell babel to use a different "importSource" instead of `React`: https://babeljs.io/docs/en/babel-plugin-transform-react-jsx#importsource https://babeljs.io/docs/en/babel-plugin-transform-react-jsx#...
- lucideer 6y ago`importSource` is just a newer version of `pragma` (I mentioned above, listed on that page below `importSource`), and works fine right now without this new transform.
- henryfjordan 6y agoI was responding to this statement: > The change described in the article makes it unnecessary to import the full React lib into each component file _when using JSX with React_. `importSource` is more than just the new `pragma`, it also handles the fancy auto-import magic. This change makes it unnecessary to import your own custom lib (not just React) into each JSX file.
- lucideer 6y agoAh ok, I get your meaning now. Yeah, it saves the need for the line in source code, but doesn't affect the generated code either way (you still need to include React somehow if using it, or whatever alternative if not)
- CGamesPlay 6y agoYou linked to the issue which appears to list the benefits of this. This is a stepping-stone change to: (from [0]) - Deprecate "module pattern" components. (ed: I don't know what this is) - Deprecate defaultProps on function components. (ed: Presumably, allowing normal param default values instead) - Deprecate spreading key from objects. (ed: Presumably, performance) - Deprecate string refs (and remove production mode _owner field). (ed: unclear how this is related) - Move ref extraction to class render time and forwardRef render time. (ed: presumably to make refs "just work" and not require the forwardRef rigamarole) - Move defaultProps resolution to class render time. (ed: performance? not sure) https://github.com/reactjs/rfcs/pull/107 https://github.com/reactjs/rfcs/pull/107 [append] Much better link: https://github.com/reactjs/rfcs/blob/createlement-rfc/text/0000-create-element-changes.md https://github.com/reactjs/rfcs/blob/createlement-rfc/text/0...