Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] createElement changes #14761

Open
eps1lon opened this issue Mar 6, 2019 · 3 comments
Open

[RFC] createElement changes #14761

eps1lon opened this issue Mar 6, 2019 · 3 comments
Labels
discussion RFC Request For Comments

Comments

@eps1lon
Copy link
Member

eps1lon commented Mar 6, 2019

This is a premature tracking issue for changes in reactjs/rfcs#107 that would affect this repository. Don't actually allocate time to this issue. Just something you might want to keep in the back of you head.

defaultProps and function components

Deprecate defaultProps on function components.

  • need to investigate implications for react-docgen
  • assuming we stick with not destructuring props in the function signature
function Component(props) {
-  const { someProp, anotherProp } = props;
+  const { someProp = 'default', anotherProp } = props;
}
-Component.defaultProps = {
-  someProp: 'defaulted'
-};

Looks doable for static analysis. If anybody encounters other patterns please post them here.

related discussions

key spreading

Deprecate spreading key from objects.

Unknown if we do this

refs

Move ref extraction to class render time and forwardRef render time.

As far as I understood this we can get rid of React.forwardRef on function components and instead of

const Component = React.forwardRef(function Component(props, ref) {
  return <div ref={ref} {...props} />;
});

do

function Component(props) {
  return <div {...props} />;
};

which is equivalent to

function Component({ ref, ...props }) {
  return <div ref={ref} {...props} />;
};

Really glad about this change. Although it would've been nice if this had landed with the findDOMNode deprecation 😩

@oliviertassinari
Copy link
Member

@eps1lon Do we need to keep this issue open? It seems that reactjs/rfcs#107 hasn't made progress.

@eps1lon
Copy link
Member Author

eps1lon commented Dec 9, 2019

I haven't made any progress in investigating if we spread keys. As long as the RFC is open this should stay open as well.

@oliviertassinari
Copy link
Member

oliviertassinari commented Dec 9, 2019

As long as the RFC is open this should stay open as well.

@eps1lon Ok, this sounds like a great strategy. I will listen to the close event on this React rfcs issue.

Capture d’écran 2019-12-09 à 11 55 34


This made me wonder. Do you think that it would be interesting for Material-UI to have an https://github.com/mui-org/rfcs repository?

@oliviertassinari oliviertassinari changed the title RE: RFC: createElement changes [RFC] createElement changes Aug 21, 2022
@oliviertassinari oliviertassinari added the RFC Request For Comments label Aug 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion RFC Request For Comments
Projects
None yet
Development

No branches or pull requests

2 participants