Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
react-prevent-router-v6
Advanced tools
Made with create-react-library
npm install --save react-prevent-router-v6
import React from 'react';
import { BrowserRouter } from 'react-router-dom';
import {
ContextPreventRouterComponent,
PreventLink
} from 'react-prevent-router-v6';
import 'react-prevent-router-v6/dist/index.css';
import CustomRoutes from './CustomRoutes';
//
const App = () => {
//
return (
<BrowserRouter>
<ContextPreventRouterComponent>
<div>
<div>
<PreventLink to={'/'}>To home</PreventLink>
</div>
<div>
<PreventLink to={'/about'}>To about</PreventLink>
</div>
<div>
<PreventLink to={'/films'}>To films</PreventLink>
</div>
<br />
<br />
<CustomRoutes />
</div>
</ContextPreventRouterComponent>
</BrowserRouter>
);
};
export default App;
import * as React from 'react';
import { Route, Routes } from 'react-router-dom';
import { usePreventRoutes } from 'react-prevent-router-v6';
import About from './About';
//
export interface CustomRoutesProps {}
//
function CustomRoutes({}: CustomRoutesProps) {
//
const { displayLocation } = usePreventRoutes({ has_effect: true });
//
return (
<Routes location={displayLocation}>
<Route path='/' element={<div>Home</div>} />
<Route path='/about' element={<About />} />
<Route path='/films' element={<div>Films</div>} />
</Routes>
);
}
export default CustomRoutes;
import * as React from 'react';
import { ContextPreventRouter } from 'react-prevent-router-v6';
//
export interface AboutProps {}
//
function About({}: AboutProps) {
//
const { handleToggleHasIp } = React.useContext(ContextPreventRouter);
//
const [value1, setValue1] = React.useState('');
const [value2, setValue2] = React.useState('');
//
const refID1 = React.useRef(0);
const refID2 = React.useRef(0);
//
React.useEffect(() => {
return () => {
refID1.current &&
handleToggleHasIp({
id: refID1.current,
has_input: false
});
refID2.current &&
handleToggleHasIp({
id: refID2.current,
has_input: false
});
};
}, []);
// ----
//
const handleChange = (
e: React.ChangeEvent<HTMLInputElement>,
refID: typeof refID1,
value: string,
setValue: typeof setValue1
) => {
const new_value = e.target.value;
if (value && new_value) {
setValue(new_value);
return;
}
const new_id = handleToggleHasIp({
id: refID.current,
has_input: !!new_value
});
refID.current = new_id;
setValue(new_value);
};
//
const handleChange1: React.ChangeEventHandler<HTMLInputElement> = (e) => {
handleChange(e, refID1, value1, setValue1);
};
//
const handleChange2: React.ChangeEventHandler<HTMLInputElement> = (e) => {
handleChange(e, refID2, value2, setValue2);
};
//
return (
<div>
<h1>About</h1>
<div>
<div>
<input type='text' value={value1} onChange={handleChange1} />
</div>
<div>
<input type='text' value={value2} onChange={handleChange2} />
</div>
</div>
</div>
);
}
export default About;
MIT © vandat9xhn
FAQs
Made with create-react-library
We found that react-prevent-router-v6 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
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.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.