1
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?

Property 'render' does not exist on type 'IntrinsicAttributes & RouteProps'

1
Last updated at Posted at 2026-02-22

はじめに

renderを使ったルーティング処理で「renderが使えない」とエラーが出てしまいました。

問題

Router
import { Login } from "../components/pages/Login";
import { homeRoutes } from "./HomeRoutes";

import { memo, FC } from "react";
import { Routes, Route } from "react-router-dom";

export const Router: FC = memo(() => {
  return (
    <Routes>
      <Route path="/" element={<Login />} />
      <Route
        path="/home"
        render={({ match: { url } }) => {
          <Routes>
            {homeRoutes.map((route) => (
              <Route key={route.path} path={`${url} ${route.path}`} />
            ))}
          </Routes>;
        }}
      />
    </Routes>
  );
});


解決方法

エラー文を確認するとrenderがないと表示されていました。

Router
import { Login } from "../components/pages/Login";
import { homeRoutes } from "./HomeRoutes";

import { memo, FC } from "react";
import { Routes, Route } from "react-router-dom";

export const Router: FC = memo(() => {
  return (
    <Routes>
      <Route path="/" element={<Login />} />
      <Route
        path="/home"
        element={
          <Routes>
            {homeRoutes.map((route) => (
              <Route
                key={route.path}
                path={route.path}
                element={route.children}
              />
            ))}
          </Routes>
        }
      />
    </Routes>
  );
});

renderのかわりにelementを用いると解決します。
elementのこととして、JSX要素を直接指定して記載します。
関数を使わずにそのまま記載できます。

おわりに

Routeの中では今後elementが中心になります。

参考

1
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
1
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?