発生している問題・エラーメッセージ
import {Redirect} from "react-router-dom";
このメンバーRedirectがありませんとエラーが起きます。
モジュール '"react-router-dom"' にエクスポートされたメンバー 'Redirect' がありません。ts(2305)
該当のソースコード
import React, {SyntheticEvent, useState} from 'react'; import {Redirect} from "react-router-dom"; const Register = () => { //登録コンポーネント }; export default Register;
試したこと
npm i react-router-dom@latest
react-router-domの更新
補足情報(FW/ツールのバージョンなど)
VScode
npx create-react-app frontend --template typescript
typrscriptでプロジェクト作成
package.json
{ "name": "frontend", "version": "0.1.0", "private": true, "dependencies": { "@testing-library/jest-dom": "^5.16.1", "@testing-library/react": "^12.1.2", "@testing-library/user-event": "^13.5.0", "@types/jest": "^27.0.3", "@types/node": "^16.11.15", "@types/react": "^17.0.37", "@types/react-dom": "^17.0.11", "react": "^17.0.2", "react-dom": "^17.0.2", "react-router-dom": "^6.2.1", "react-scripts": "5.0.0", "typescript": "^4.5.4", "web-vitals": "^2.1.2" }, "scripts": { "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject" }, "eslintConfig": { "extends": [ "react-app", "react-app/jest" ] }, "browserslist": { "production": [ ">0.2%", "not dead", "not op_mini all" ], "development": [ "last 1 chrome version", "last 1 firefox version", "last 1 safari version" ] } }
回答1件
あなたの回答
tips
プレビュー