0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

React.js 18 以降 React.FC で childrenが削除される対処法

Posted at

型定義でReact.FCchildrenの暗黙的型定義が含まれていたが、
React.js 18 以降 childrenの暗黙的型定義が外された。

ではchildrenの型はどのように指定するか?

children: React.ReactNode という感じで、 React.ReactNodeと、型定義する。

import React from 'react';

interface props {
  children: React.ReactNode;
}

const Text:React.FC<props> = ({ children }) => {
  return (
    <p>{ children }</p>
  )
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?