From 050e1c182c5c11c535614f6f65b6c432d41d89c1 Mon Sep 17 00:00:00 2001 From: Paul Le Cam Date: Sun, 12 Jul 2020 11:27:23 +0100 Subject: [PATCH] v3 beta 1 --- .gitignore | 2 +- CHANGELOG.md | 13 +++ README.md | 2 +- UPGRADING.md | 132 ---------------------------- package.json | 2 +- packages/core/README.md | 3 + packages/core/package.json | 2 +- packages/react-leaflet/README.md | 3 + packages/react-leaflet/package.json | 4 +- yarn.lock | 14 +-- 10 files changed, 32 insertions(+), 145 deletions(-) delete mode 100644 UPGRADING.md create mode 100644 packages/core/README.md create mode 100644 packages/react-leaflet/README.md diff --git a/.gitignore b/.gitignore index be12cc60..ac00ef44 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ node_modules -.now \ No newline at end of file +.vercel \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a6f8fb0..e64b422c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,16 @@ +## v3.0.0-beta.1 (2020-07-12) + +v3 is a full rewrite of React Leaflet and contains breaking change from v2. + +- Full rewrite based on [React Hooks](https://reactjs.org/docs/hooks-intro.html) (no more extending `Component`) +- Replace Flow by TypeScript for type checking +- Drop IE support (Babel config will only target the "last 2 versions" of browsers) +- Switch to the [Hippocratic License](https://firstdonoharm.dev/) +- The `Map` component is replaced by [`MapContainer`](https://react-leaflet-v3.now.sh/docs/api-map#mapcontainer), behaving differently +- Event handlers must be attached using the [`eventHandlers prop`](https://react-leaflet-v3.now.sh/docs/api-components#evented-behavior) rather than `on*` props, with a similar change for [path options](https://react-leaflet-v3.now.sh/docs/api-components#path-behavior) and [WMS params](https://react-leaflet-v3.now.sh/docs/api-components#wmstilelayer) +- The `react-leaflet` package only exposes a [public API](https://react-leaflet-v3.now.sh/docs/api-map) while a new package, `@react-leaflet/core`, is used to provide the [core APIs](https://react-leaflet-v3.now.sh/docs/core-introduction) +- A new documentation website using [Docusaurus v2](https://v2.docusaurus.io/) with live examples, currently published on [react-leaflet-v3.now.sh](https://react-leaflet-v3.now.sh/) + ## v2.7.0 (2020-05-06) - Added `viewBox` and `preserveAspectRatio` props to `SVGOverlay` component ([PR #704](https://github.com/PaulLeCam/react-leaflet/pull/704) by _spectras_). diff --git a/README.md b/README.md index a7161ef2..a7ea1fd6 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# React-Leaflet v3 [![Build Status](https://img.shields.io/travis/PaulLeCam/react-leaflet/next.svg)](https://travis-ci.org/PaulLeCam/react-leaflet) [![npm version](https://img.shields.io/npm/v/react-leaflet/next.svg)](https://www.npmjs.com/package/react-leaflet) +# React Leaflet v3 [![Build Status](https://img.shields.io/travis/PaulLeCam/react-leaflet/next.svg)](https://travis-ci.org/PaulLeCam/react-leaflet) [![npm version](https://img.shields.io/npm/v/react-leaflet/next.svg)](https://www.npmjs.com/package/react-leaflet) This is the development branch of React Leaflet v3, for the stable v2, use the master branch. diff --git a/UPGRADING.md b/UPGRADING.md deleted file mode 100644 index c7fd9d01..00000000 --- a/UPGRADING.md +++ /dev/null @@ -1,132 +0,0 @@ -# Upgrading - -## v2.6 - -This release requires [Leaflet v1.6](https://leafletjs.com/2019/11/17/leaflet-1.6.0.html) as peer dependency. - -## v2.3 - -This release requires [Leaflet v1.5](https://leafletjs.com/2019/05/08/leaflet-1.5.0.html) and [React v16.8](https://reactjs.org/blog/2019/02/06/react-v16.8.0.html) as peer dependencies. - -## v2.2 - -This release requires [Leaflet v1.4](https://leafletjs.com/2018/12/30/leaflet-1.4.0.html) as peer dependency. - -## v2 - -This release requires [React v16.3](https://reactjs.org/blog/2018/03/29/react-v-16-3.html) and brings breaking changes in the way the necessary context is propagated. Most third-party plugins and custom components will likely need to be updated in order to access the context. - -## v1.8 - -This release requires [Leaflet v1.3](http://leafletjs.com/2018/01/15/leaflet-1.3.0.html) as peer dependency. - -## v1.6 - -This release makes internal changes to the folders exposed: - -- The `src` folder is no longer exported in the npm package, the added `es` one should be consumed instead if you want to support modules. -- The `lib` and `dist` folders are no longer exported in the GitHub repository, use the npm package instead if you need to access them. - -## v1.5 - -This release requires [Leaflet v1.2](http://leafletjs.com/2017/08/08/leaflet-1.2.0.html) as peer dependency. - -## v1.4 - -This release requires [Leaflet v1.1](http://leafletjs.com/2017/06/27/leaflet-1.1.0.html) in order to support the newly added features such as dynamic z-index in `ImageOverlay` and the `VideoOverlay` layer, exposed by React-Leaflet as a component. - -The `prop-types` package is now set as a peer dependency rather than a direct dependency, so you will need to add it to your application dependencies if not already set. - -## v1.1 - -This release changes the way Leaflet elements are created and updated internally. If you are only using public APIs, nothing should change, however if you are extending or creating custom components, you should now use the added `createLeafletElement()` and `updateLeafletElement()` methods described in the [Extending](https://github.com/PaulLeCam/react-leaflet/blob/master/docs/Extending.md#extending) section of the documentation rather than overriding the lifecycle hooks directly.\ -See the [relevant commit](https://github.com/PaulLeCam/react-leaflet/commit/b42026f9dc93be45f0b8ffc6638a9d3824751091) for more details about the changes involved. - -## v1.0 - -React-Leaflet v1 requires Leaflet v1.0.0 and therefore contains breaking changes from v0.12, based on Leaflet v0.7.\ -Make sure to update your Leaflet dependency to v1.0.0, as well as its CSS file. - -The following list includes breaking changes upgrading to React-Leaflet v1.0 from v0.12, it may not be exhaustive: - -- Renamed `GeoJson` to `GeoJSON` to match Leaflet's change. -- Removed `MultiPolygon` and `MultiPolyline`, now supported by `Polygon` and `Polyline` respectively. -- Removed `CanvasTileLayer`, replaced by `GridLayer`. See [Leaflet's documentation](http://leafletjs.com/reference-1.0.0.html#gridlayer). -- Removed `getLeafletElement()` method in `MapComponent` and `MapControl`, deprecated since v0.12.0. -- Removed `setIconDefaultImagePath()` helper, set `Leaflet.Icon.Default.imagePath` directly using Leaflet if you need. - -Read the [changelog](CHANGELOG.md) for more details about these changes. - -## v0.12.0 - -**Drop support for IE <= 10** as explained in [this comment](https://github.com/PaulLeCam/react-leaflet/issues/215#issuecomment-243996907). - -**Deprecated:** the `getLeafletElement()` method on components is deprecated, you can simply use the `leafletElement` property instead. - -The major change in this version is the use of [context](https://facebook.github.io/react/docs/context.html) instead of props to pass Leaflet instances from components to their children.\ -If you are only using the components provided by React-Leaflet, everything should continue to work as before. - -If you are using custom components, you may have to update your code to provide or access the `map`, `layerContainer` and `popupContainer` using context.\ -For example, using React-Leaflet < 0.12, you would need to do: - -```js -// layerContainer and map need to be passed to Marker -const MyPopupMarker = ({ layerContainer, map, position, children }) => ( - - - {children} - - -) - -// layerContainer and map need to be passed through to its children -const MyMarkersList = ({ layerContainer, map, markers }) => { - const items = markers.map(({ key, ...props }) => ( - - )) - return
{items}
-} - -const CustomComponent = () => { - const markers = [ - { key: 'marker1', position: [51.5, -0.1], children: 'My first popup' }, - { key: 'marker2', position: [51.51, -0.1], children: 'My second popup' }, - { key: 'marker3', position: [51.49, -0.05], children: 'My third popup' }, - ] - return ( - - - - - ) -} -``` - -Using React-Leaflet >= 0.12, it becomes simpler: - -```js -// Marker will get `layerContainer` and `map` from context -const MyPopupMarker = ({ children, position }) => ( - - - {children} - - -) - -// No need to inject `layerContainer` and `map` props to the children -const MyMarkersList = ({ markers }) => { - const items = markers.map(({ key, ...props }) => ( - - )) - return
{items}
-} -``` diff --git a/package.json b/package.json index 1aa32126..04d97c19 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "@testing-library/react-hooks": "^3.3.0", "@types/jest": "^26.0.4", "@types/leaflet": "^1.5.16", - "@types/react": "^16.9.42", + "@types/react": "^16.9.43", "@types/react-dom": "^16.9.8", "@types/warning": "^3.0.0", "@typescript-eslint/eslint-plugin": "^3.6.0", diff --git a/packages/core/README.md b/packages/core/README.md new file mode 100644 index 00000000..f7b405e8 --- /dev/null +++ b/packages/core/README.md @@ -0,0 +1,3 @@ +# React Leaflet core + +[Documentation](https://react-leaflet-v3.now.sh/docs/core-introduction) diff --git a/packages/core/package.json b/packages/core/package.json index 0ae41468..aeda978b 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@react-leaflet/core", - "version": "1.0.0-alpha.1", + "version": "1.0.0-beta.2", "description": "React Leaflet core", "main": "cjs/index.js", "module": "esm/index.js", diff --git a/packages/react-leaflet/README.md b/packages/react-leaflet/README.md new file mode 100644 index 00000000..7bb2d554 --- /dev/null +++ b/packages/react-leaflet/README.md @@ -0,0 +1,3 @@ +# React Leaflet v3 + +Work in progress documentation is available on [react-leaflet-v3.now.sh](https://react-leaflet-v3.now.sh/). diff --git a/packages/react-leaflet/package.json b/packages/react-leaflet/package.json index cce7539d..df484471 100644 --- a/packages/react-leaflet/package.json +++ b/packages/react-leaflet/package.json @@ -1,6 +1,6 @@ { "name": "react-leaflet", - "version": "3.0.0-alpha.0", + "version": "3.0.0-beta.1", "description": "React components for Leaflet maps", "main": "cjs/index.js", "module": "esm/index.js", @@ -44,7 +44,7 @@ ], "dependencies": { "@babel/runtime-corejs3": "^7.10.4", - "@react-leaflet/core": "^1.0.0-alpha.1", + "@react-leaflet/core": "^1.0.0-beta.2", "core-js": "^3.6.5" }, "peerDependencies": { diff --git a/yarn.lock b/yarn.lock index 8ccfeb00..16e0bfa5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1937,10 +1937,10 @@ dependencies: "@types/react" "*" -"@types/react@*", "@types/react@^16.9.42": - version "16.9.42" - resolved "https://registry.yarnpkg.com/@types/react/-/react-16.9.42.tgz#9776508d59c1867bbf9bd7f036dab007fdaa1cb7" - integrity sha512-iGy6HwfVfotqJ+PfRZ4eqPHPP5NdPZgQlr0lTs8EfkODRBV9cYy8QMKcC9qPCe1JrESC1Im6SrCFR6tQgg74ag== +"@types/react@*", "@types/react@^16.9.43": + version "16.9.43" + resolved "https://registry.yarnpkg.com/@types/react/-/react-16.9.43.tgz#c287f23f6189666ee3bebc2eb8d0f84bcb6cdb6b" + integrity sha512-PxshAFcnJqIWYpJbLPriClH53Z2WlJcVZE+NP2etUtWQs2s7yIMj3/LDKZT/5CHJ/F62iyjVCDu2H3jHEXIxSg== dependencies: "@types/prop-types" "*" csstype "^2.2.0" @@ -3224,9 +3224,9 @@ caniuse-api@^3.0.0: lodash.uniq "^4.5.0" caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000981, caniuse-lite@^1.0.30001035, caniuse-lite@^1.0.30001093, caniuse-lite@^1.0.30001097: - version "1.0.30001097" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001097.tgz#1129c40c9f5ee3282158da08fd915d301f4a9bd8" - integrity sha512-TeuSleKt/vWXaPkLVFqGDnbweYfq4IaZ6rUugFf3rWY6dlII8StUZ8Ddin0PkADfgYZ4wRqCdO2ORl4Rn5eZIA== + version "1.0.30001099" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001099.tgz#540118fcc6842d1fde62f4ee5521d1ec6afdb40e" + integrity sha512-sdS9A+sQTk7wKoeuZBN/YMAHVztUfVnjDi4/UV3sDE8xoh7YR12hKW+pIdB3oqKGwr9XaFL2ovfzt9w8eUI5CA== capture-exit@^2.0.0: version "2.0.0"