---
title: "Discussion on \"An easier way to add types for \"children\" in React\" | Hashnode"
description: "Discussion on \"An easier way to add types for \"children\" in React\". Something I had been struggling with since I started using React up until a few months ago was finding a good type to set for the children prop.\nThe typical route I would take is to sorta just add the types as I needed them to a union like so:\ninterf..."
url: "https://hashnode.com/posts/props-with-children-react-typescript/6042741891eeac2b7aee83ba"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [An easier way to add types for "children" in React](https://ozzie.sh/props-with-children-react-typescript?utm_source=hashnode&utm_medium=feed)

Something I had been struggling with since I started using React up until a few months ago was finding a good type to set for the children prop. The typical route I would take is to sorta just add the types as I needed them to a union like so: interf...

Mar 5, 2021 · 4 min read · ozzie.sh  
Read the article

-   [#reactjs](https://hashnode.com/tag/reactjs)
-   [#typescript](https://hashnode.com/tag/typescript)
-   [#react-native](https://hashnode.com/tag/react-native)
-   [#javascript](https://hashnode.com/tag/javascript)

## Written by

[Ozzie Neher](https://hashnode.com/@ozziexsh)

@ozziexsh · Saskatoon, SK, Canada

  
[View profile](https://hashnode.com/@ozziexsh)

Full Stack Dev

## Responses 1

Markdown supported · ⌘↵ to post

[shadowtime2000](https://hashnode.com/@shadowtime2000)

[Mar 6, 2021](https://hashnode.com/posts/props-with-children-react-typescript/6042741891eeac2b7aee83ba/comment/6042e05991eeac2b7aee885f)

You could also do

```
import type { PropsWithChildren } from "react";
```

because it's easier for build tools to know it's a type import so they can remove it without ruining the output of the code.

[Ozzie Neher](https://hashnode.com/@ozziexsh)

[Mar 6, 2021](https://hashnode.com/posts/props-with-children-react-typescript/6042741891eeac2b7aee83ba/comment/6042e05991eeac2b7aee885f#reply-6043afc95a56f82fa3ecbef7)

Interesting! I'd never heard of `import type` until your comment. The more ya know!

[typescriptlang.org/docs/handbook/release-notes/ty…](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
