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

Idea: Shorthand Property Initialization #22039

Closed
ethanlal04 opened this issue Aug 6, 2021 · 2 comments
Closed

Idea: Shorthand Property Initialization #22039

ethanlal04 opened this issue Aug 6, 2021 · 2 comments
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug

Comments

@ethanlal04
Copy link

ethanlal04 commented Aug 6, 2021

Hello,

export default function App() {
  const src = "https://picsum.photos/200";

  return (
    <img src={src} alt="A random image" />
  );
}

Above, the value of the src property is the src variable. In such a case, Svelte lets us exclude the repetitive attribute like this...

<img {src} alt="A random image" />

I'd like to have the same in React. I think this would make the code more concise. Thank you 😀.

@ethanlal04 ethanlal04 added the Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug label Aug 6, 2021
@bvaughn
Copy link
Contributor

bvaughn commented Aug 6, 2021

This has been proposed a few times: #9696, #9707, #13967, #15731, #20164, #21236

The place to request/suggest this is the JSX repo though, specifically: facebook/jsx#23

I'm going to close this issue and suggest you join the discussion on that one. 👍🏼

@bvaughn bvaughn closed this as completed Aug 6, 2021
@ethanlal04
Copy link
Author

ethanlal04 commented Aug 6, 2021

Oops, I didn't see that. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug
Projects
None yet
Development

No branches or pull requests

2 participants