【发布时间】:2021-08-05 16:00:10
【问题描述】:
我刚刚使用create-react-app 开始了一个全新的项目,并按照他们的文档推荐的here 设置了react-leaflet。
我正在尝试使用this example 来检查它是否一切正常,但随后我收到以下错误:
./node_modules/@react-leaflet/core/esm/path.js 10:41
Module parse failed: Unexpected token (10:41)
File was processed with these loaders:
* ./node_modules/react-scripts/node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
| useEffect(function updatePathOptions() {
| if (props.pathOptions !== optionsRef.current) {
> const options = props.pathOptions ?? {};
| element.instance.setStyle(options);
| optionsRef.current = options;
看起来react-scripts 无法处理react-leaflet 文件。
有人可以帮助我了解为什么会发生这种情况以及如何解决它吗?
【问题讨论】:
标签: create-react-app react-leaflet