Recently i am working on reactjs+typescript project in which i would like to add maps functionality using react-leaflet plugin, i correctly followed the documentation that can be found in https://react-leaflet.js.org but the problem is that after setting up everything the app isn't able to run, the error presented is as follows below:
./node_modules/@react-leaflet/core/lib/path.js 10:39
Module parse failed: Unexpected token (10:39)
You may need an appropriate loader to handle this file type.
| useEffect(function updatePathOptions() {
| if (props.pathOptions !== optionsRef.current) {
var options = props.pathOptions ?? {};
| element.instance.setStyle(options);
| optionsRef.current = options;
One of the recommendation i followed in order to fix the problem was to change the browserslist in the package.json from:
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
To:
"browserslist": [
">0.2%",
"not dead",
"not op_mini all"
],
And then delete the cache folder in node modules and restart the app, but it didn't fix the problem.
I don't know why it's not working in react 18, downgrading the react-leaflet version is not an option because as the documentation says react 18 only works with react leaflet 4 which is the latest version.
any help would be appreciated, Thanks.