Props shorthand in Reactjs

Viewed 102

In Svelte we can use shorthand when attribute and its value have the same name. E.g.:

<img src={src} alt="">

is the same as:

<img {src} alt="">

My question is whether there is a possibility to do the same in React.js? E.g.:

<button {type}>Click me!</button>
1 Answers

No, you can't do it. But you can use spread operator to pass the list props.

const props = {src, type};

<button {...props}>Click me!</button>
Related