Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add children to InertiaHeadProps type #1448

Merged
merged 1 commit into from
Feb 15, 2023

Conversation

stephenglass
Copy link
Contributor

@stephenglass stephenglass commented Feb 14, 2023

PR for Issue #1437

The Problem

In React 18, the React.FC interface removed the children prop. Therefore, as seen in the issue, any use of children in Inertia Head component will produce a type error. The use of children in this component is required to set meta tags as shown in the official Inertia documentation:

import { Head } from '@inertiajs/react'

<Head>
  <title>Your page title</title>
  <meta name="description" content="Your page description" />
</Head>

However, this code results in the following error:
Type '{ children: Element[]; }' has no properties in common with type 'IntrinsicAttributes & InertiaHeadProps'.

Replication

  1. Install dependencies:@types/react and @types/react-dom (credit to @nogenem)
  2. View error in Inertia React TypeScript playground

Fix

This PR explicitly adds the children props to the InertiaHeadProps type which resolves the type issue when using children to set title or meta tags in the Head component.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants