I want to upgrade the react-router
package to v6
. It has a dependency on the history
package, and in the history
package roadmap, the document says history.length
will be deprecated and even deleted soon. You can take a look https://github.com/remix-run/history/issues/689
I wonder if there are other alternatives for using history.length
in my code while upgrading the react-router
package to the latest version.
As an example, one of my usage of it:
import { useHistory } from 'react-router';
const history = useHistory();
const onGoBack = () => {
if (history.length > 2) {
history.goBack();
} else {
history.push('/portfolio');
}
};