@wenle_2523097/agri-map 1.0.8 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +10 -9
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -25,27 +25,28 @@ yarn add @wenle_2523097/agri-map
25
25
  确保项目已安装以下**指定版本**的依赖:
26
26
 
27
27
  ```bash
28
- # 必需依赖(版本要求)
29
- npm install leaflet@^1.9.4 react@^18.0.0 react-dom@^18.0.0 react-leaflet@^4.2.1
30
-
31
- # 或使用以下命令安装推荐版本
28
+ # 方案 1:React 18 + react-leaflet v4(推荐,最稳定)
32
29
  npm install leaflet@1.9.4 react@18.3.1 react-dom@18.3.1 react-leaflet@4.2.1
30
+
31
+ # 方案 2:React 19 + react-leaflet v5(需要禁用 StrictMode)
32
+ npm install leaflet@1.9.4 react@19.2.4 react-dom@19.2.4 react-leaflet@5.0.0
33
33
  ```
34
34
 
35
35
  > ⚠️ **重要提示:**
36
- > - `react-leaflet` 必须使用 **v4.x** 版本,v5.x 版本 API 不兼容
37
- > - `react` 推荐使用 **v18.x** 版本,v19.x 需要禁用 StrictMode
36
+ > - `react-leaflet` 支持 **v4.x** 和 **v5.x** 版本
37
+ > - 使用 **v5.x** 时需要 React 19,且必须禁用 StrictMode(见下方说明)
38
+ > - 推荐优先使用 **v4.x** 版本,兼容性更好
38
39
 
39
- ### React 19 注意事项
40
+ ### React 19 / react-leaflet v5 注意事项
40
41
 
41
- 如果你使用的是 React 19,需要在入口文件中**禁用 StrictMode**,否则 Leaflet 地图容器会报错 "Map container is already initialized":
42
+ 如果你使用的是 React 19 或 react-leaflet v5,需要在入口文件中**禁用 StrictMode**,否则 Leaflet 地图容器会报错 "Map container is already initialized":
42
43
 
43
44
  ```jsx
44
45
  // src/main.jsx 或 src/main.tsx
45
46
  import { createRoot } from 'react-dom/client'
46
47
  import App from './App'
47
48
 
48
- // ❌ 不要使用 StrictMode
49
+ // ❌ 不要使用 StrictMode(会导致 Leaflet 重复初始化)
49
50
  createRoot(document.getElementById('root')).render(
50
51
  <App />
51
52
  )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wenle_2523097/agri-map",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "农业地图组件库 - 基于React-Leaflet的农业专用地图组件",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
@@ -35,7 +35,7 @@
35
35
  "leaflet": "^1.9.4",
36
36
  "react": ">=18.0.0",
37
37
  "react-dom": ">=18.0.0",
38
- "react-leaflet": "^4.2.1"
38
+ "react-leaflet": "^4.2.1 || ^5.0.0"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@babel/core": "^7.23.9",