loading...

Pass props using spread operator

318097 profile image Mehul Lakhanpal Originally published at codedrops.tech ・1 min read
const cardProps = { title: "Card Title", content: "Hello  World" };

const App = () => {
  return (
    <Card
      title={cardProps.title}
      content={cardProps.content}
    />
  );
};

Simpler way to do this:

const cardProps = { title: "Card Title", content: "Hello  World" };

const App = () => {
  return <Card {...cardProps} />;
};

Discussion

pic
Editor guide