ychengcloud / react-vite-admin Goto Github PK
View Code? Open in Web Editor NEWThis Starter utilizes React, Recoil, React Query, React Hooks, Typescript, Axios And Vite. 全新技术栈的后台管理系统
License: MIT License
This Starter utilizes React, Recoil, React Query, React Hooks, Typescript, Axios And Vite. 全新技术栈的后台管理系统
License: MIT License
您好,看了下您的项目有几个问题想请教下
1 看你在请求拦截那里跳转登陆用的是 window.location.href = '/login'; 然后我看您也引入了 const history = createBrowserHistory(); 是原本打算用history跳转然后不生效嘛?
2 我看 react-router-dom V6 中 unstable_HistoryRouter这个路由可以实现在js|ts下跳转路由
3 react-router-dom中也增加了很多特别好用的 方法 createBrowserRouter 和 RouterProvider 以及Route也增加了很多属性 像loader 可以登陆拦截 errorElement可以做到errorboundary等功能
4 但是上述第三点只能通过createBrowserRouter方法实现,和我第二点又冲突了~~
5 所以我现在的问题是 如何通过 createBrowserRouter 和 RouterProvider创建路由,又能在js|ts文件下跳转路由而不是用window.location.href~~
renderz@renderzdeMacBook-Pro react-vite-admin % yarn build
yarn run v1.22.0
$ tsc && vite build
node_modules/@ant-design/pro-form/lib/components/ColorPicker/index.d.ts:2:40 - error TS7016: Could not find a declaration file for module 'react-color'. '/Users/renderz/github/react-vite-admin/node_modules/react-color/lib/index.js' implicitly has an 'any' type.
Try npm i --save-dev @types/react-color
if it exists or add a new declaration (.d.ts) file containing declare module 'react-color';
2 import type { SketchPickerProps } from 'react-color';
~~~~~~~~~~~~~
node_modules/@ant-design/pro-layout/lib/typings.d.ts:2:15 - error TS2305: Module '"react-router-dom"' has no exported member 'RouteComponentProps'.
2 import type { RouteComponentProps as BasicRouteProps, match } from 'react-router-dom';
~~~~~~~~~~~~~~~~~~~
node_modules/@ant-design/pro-layout/lib/typings.d.ts:2:55 - error TS2305: Module '"react-router-dom"' has no exported member 'match'.
2 import type { RouteComponentProps as BasicRouteProps, match } from 'react-router-dom';
~~~~~
node_modules/@ant-design/pro-layout/lib/typings.d.ts:5:11 - error TS2694: Namespace '"/Users/renderz/github/react-vite-admin/node_modules/history/index"' has no exported member 'LocationDescriptor'.
5 to: H.LocationDescriptor;
~~~~~~~~~~~~~~~~~~
node_modules/@antv/g6-core/lib/index.d.ts:1:23 - error TS2688: Cannot find type definition file for '_gl-matrix@3.3.0@gl-matrix'.
因为是刚开始上手react用您的项目来学习 想知道路由抽离出去之后怎么使用 所以比较关注这个问题
观察打印的 console log 可以看到每个页面渲染了两次
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.