router icon indicating copy to clipboard operation
router copied to clipboard

fix(react-router): accept valid ReactNode as route component

Open honzahruby opened this issue 1 year ago • 3 comments

In route.ts, there's a custom alias for ReactNode set to any. Based on the commit history alone, it looks like it was introduced for backward compatibility with typescript <5.1. This PR conditionally uses the real type from react if typescript >5.0 is available.

Using any allowed to pass any function as a route component, even when it wasn't a valid react component, causing a runtime crash.

honzahruby avatar Aug 27 '24 09:08 honzahruby

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 671ce5ed97d6e5b1ac66c550b9d94870c355c65f. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 2 targets

Sent with 💌 from NxCloud.

nx-cloud[bot] avatar Aug 27 '24 09:08 nx-cloud[bot]

Open in Stackblitz

More templates

@tanstack/history

pnpm add https://pkg.pr.new/@tanstack/history@2194
@tanstack/react-cross-context

pnpm add https://pkg.pr.new/@tanstack/react-cross-context@2194
@tanstack/react-router-with-query

pnpm add https://pkg.pr.new/@tanstack/react-router-with-query@2194
@tanstack/router-arktype-adapter

pnpm add https://pkg.pr.new/@tanstack/router-arktype-adapter@2194
@tanstack/router-cli

pnpm add https://pkg.pr.new/@tanstack/router-cli@2194
@tanstack/router-devtools

pnpm add https://pkg.pr.new/@tanstack/router-devtools@2194
@tanstack/router-plugin

pnpm add https://pkg.pr.new/@tanstack/router-plugin@2194
@tanstack/router-generator

pnpm add https://pkg.pr.new/@tanstack/router-generator@2194
@tanstack/react-router

pnpm add https://pkg.pr.new/@tanstack/react-router@2194
@tanstack/router-valibot-adapter

pnpm add https://pkg.pr.new/@tanstack/router-valibot-adapter@2194
@tanstack/router-vite-plugin

pnpm add https://pkg.pr.new/@tanstack/router-vite-plugin@2194
@tanstack/router-zod-adapter

pnpm add https://pkg.pr.new/@tanstack/router-zod-adapter@2194
@tanstack/start

pnpm add https://pkg.pr.new/@tanstack/start@2194
@tanstack/start-vite-plugin

pnpm add https://pkg.pr.new/@tanstack/start-vite-plugin@2194

commit: 671ce5e

pkg-pr-new[bot] avatar Aug 27 '24 09:08 pkg-pr-new[bot]

@SeanCassiere Would you have a look? 🙏

honzahruby avatar Aug 27 '24 13:08 honzahruby

Closing this PR, as the minimum typescript version has been moved up to 5.2 as listed on the website.

@honzahruby thank you for contributing towards this! we do very much appreciate it!

SeanCassiere avatar Sep 19 '24 01:09 SeanCassiere