0

I'm not sure what I'm looking at here. I'm learning TypeScript and React at the same time, and I've come across a JavaScript snippet that defines a function that accepts an object as the parameter. I'm converting the JS to TSX. My TypeScript linter flags it as an implicit any type and I'd like to correct it; however, I need to understand this syntax first. I imagine this is an ES6 thing, but I don't even know the term for it to learn more:

import * as React from "react";

export default function Layout({ children }) {
  return (
     <div>
      <h1>Hello, world!</h1>
      {children}
    </div>
  );
}

Logically, React will expand the {children} object, but I'd like to learn more about this syntax. What is this called?

1 Answers1

0

You're probably looking for Destructuring in ES6/ES2015

Dan D
  • 2,493
  • 15
  • 23