![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
react-router6-prompt
Advanced tools
由于目前react-router6中仍未支持 Prompt,但是在有些时候不得不使用此功能,所以此模块,仅实现此功能仅此而已。
npm install react-router6-prompt
首先导入Router,包括 BrowserRouter
和 HashRouter
两种模式。
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
// 使用HashRouter,同样的方法导入即可
import {BrowserRouter} from 'react-router-prompt';
ReactDOM.render(
<React.StrictMode>
<HashRouter>
<App />
</HashRouter>
</React.StrictMode>,
document.getElementById('root')
)
在需要使用Prompt功能的页面内添加
import React from 'react';
import {browserHistory, Prompt} from 'react-router6-prompt';
// 如果使用的是HashRouter,这里引入hashHistory即可。
const Page = () => {
return (
<>
<Prompt history={browserHistory} when={true} message={() => {
return true;
}}>
</Prompt>
);
}
export default Page;
在使用 Prompt
组件时,该组件有三个prop
参数:
history
,支持 browserHistory
和hashHistory
。when
,boolean,设置是否开启页面切换或卸载效验。message
,string
、 () => boolean
、() => Promise<boolean>
支持三种类型,使用 string
作为参数则使用浏览器默认的 confirm
作为页面切换或卸载时的确认控件,使用后面两种则可以自定义切换或卸载时的控件控件。FAQs
为react-router6附加prompt功能
The npm package react-router6-prompt receives a total of 2 weekly downloads. As such, react-router6-prompt popularity was classified as not popular.
We found that react-router6-prompt demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.