chrome back button click event react
import { useHistory } from 'react-router-dom'
const [ locationKeys, setLocationKeys ] = useState([])
const history = useHistory()
useEffect(() => {
return history.listen(location => {
if (history.action === 'PUSH') {
setLocationKeys([ location.key ])
}
if (history.action === 'POP') {
if (locationKeys[1] === location.key) {
setLocationKeys(([ _, ...keys ]) => keys)
// Handle forward event
} else {
setLocationKeys((keys) => [ location.key, ...keys ])
// Handle back event
}
}
})
}, [ locationKeys, ])const {history} = useRouter();
useEffect(() => {
return () => {
// && history.location.pathname === "any specific path")
if (history.action === "POP") {
history.replace(history.location.pathname, /* the new state */);
}
};
}, [history])
Also in JavaScript:
- Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx) call?
- uirouter
- angular material theme colors
- heroku failed to run files from static folder in node
- has own propriety javascrip
- javascript double question mark
- how do you create a function js?
- iife
- <IfModule mod_rewrite.c> RewriteEngine on RewriteRule ^(\.well-known/.*)$ $1 [L] RewriteRule ^$ webroot/ [L] RewriteRule (.*) webroot/$1 [L] RewriteCond %{HTTP:Authorization} ^(.*) RewriteRule .* - [e=HTTP_AUTHORIZATION:%1] </IfModule>
- do you need a semicolon in javascript
- async await react stackoverflow
- settimeout in vuejs
- how to stop the node server from running
- node js change text color
- settimeout jquery
- react memo
- node js write read string to file
- app.router.navigate reset framework7
- react suspense chunck
- js access sql database on server
- js propagation stop
- what foreach method returns in javascript
- angular material input
- react js router parameters