After upgrading to 4.3.1 i get the following typescript error
generatePath.js?3f47:13 Uncaught TypeError: path_to_regexp__WEBPACK_IMPORTED_MODULE_0___default.a.compile is not a function
at compileGenerator (generatePath.js?3f47:13)
at generatePath (generatePath.js?3f47:33)
at Redirect.computeTo (Redirect.js?6842:62)
at Redirect.perform (Redirect.js?6842:77)
at Redirect.componentDidMount (Redirect.js?6842:41)
at commitLifeCycles (react-dom.development.js?f8c1:14248)
at commitAllLifeCycles (react-dom.development.js?f8c1:15342)
at HTMLUnknownElement.callCallback (react-dom.development.js?f8c1:100)
at Object.invokeGuardedCallbackDev (react-dom.development.js?f8
I think the import statement in generatePath.js should be
import * as pathToRegexp from "path-to-regexp";
instead of
import pathToRegexp from "path-to-regexp";
I had the same issue. I checked path-to-regexp the downloaded package and for some reason, it downgraded to old 0.1.7.
This dependency version comes from express.js and there is no lock-in in react-router.
The quick solution is to add this package to your project
npm i path-to-regexp --save
I ran into this issue today. Is there going to be a fix or should I plan on having path-to-regexp in my deps for the foreseeable future?
It鈥榮 a workaround but no real solution.
@timdorr can you explain why this was closed?
@timdorr This should not be marked as closed. This is a very real issue on the latest stable.
declare var require: any;
const pathToRegexp = require('path-to-regexp');
This work for me.
Most helpful comment
@timdorr This should not be marked as closed. This is a very real issue on the latest stable.