# leaflet-react-fibers

> A high performance react library for [leafletjs](https://www.leafletjs.com)

Latest version **2.0.2** (published 2024-03-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install leaflet-react-fibers
pnpm add leaflet-react-fibers
yarn add leaflet-react-fibers
bun add leaflet-react-fibers
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.2 |
| Published | 2024-03-19 |
| First published | 2021-12-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >= 14 |
| Dependencies | 2 |
| Unpacked size | 1.5 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | chickencoding123 |
| Maintainers | ironincoder |
| Keywords | leaflet, react, fibers, leaflet-jsx, react-leaflet, leaflet-react |

## Links

- npm: https://www.npmjs.com/package/leaflet-react-fibers
- Repository: https://github.com/chickencoding123/leaflet-react-fibers
- Homepage: https://github.com/chickencoding123/leaflet-react-fibers#readme
- Issues: https://github.com/chickencoding123/leaflet-react-fibers/issues
- npm.io page: https://npm.io/package/leaflet-react-fibers

## Dependencies (2)

- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [react-reconciler](https://npm.io/package/react-reconciler.md) ^0.26.0

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 2.0.2 (latest) — 2024-03-19
- 2.0.1 — 2022-10-28
- 2.0.0 — 2022-10-28
- 1.1.0 — 2022-02-25
- 1.0.3 — 2022-01-06
- 1.0.2 — 2021-12-26
- 1.0.1 — 2021-12-25

## README

<div align="center">

<img src="./stories/assets/leaflet-react-fibers.png" style="width: 10rem; margin-bottom: 1rem" alt="leaflet-react-fibers logo" />

<h1>leaflet-react-fibers</h1>

A high performance react library for _[leafletjs](https://www.leafletjs.com)_

[![npm](https://img.shields.io/npm/dm/leaflet-react-fibers?label=npm&logo=npm&color=blue)](https://www.npmjs.com/package/leaflet-react-fibers) [![license](https://img.shields.io/npm/l/leaflet-react-fibers?color=blue)](https://github.com/chickencoding123/leaflet-react-fibers/blob/main/LICENSE) [![docs](https://img.shields.io/badge/demo%20and%20docs-blue?label=see&logo=readthedocs)](https://chickencoding123.github.io/leaflet-react-fibers)

</div>

## How to use
```sh
npm i leaflet-react-fibers --save
# or
yarn add leaflet-react-fibers --save
```
```tsx
import { LeafletMap, L } from "leaflet-react-fibers"

const JustAMap = () => {
  return (
    <LeafletMap options={{ crs: L.CRS.Simple }}>
      <lfRectangle bounds={[[50, 50], [150, 100]]} options={{ fillColor: 'black' }} add={() => { console.log('added a rectangle layer') }} />
    </LeafletMap>
  )
}
```
See [Docs](https://chickencoding123.github.io/leaflet-react-fibers) for various examples.

### JSX renderer
You must provide a JSX renderer when embedding HTML in `lfPopup` or `lfTooltip` otherwise their contents are ignored, this is by design:
>:information_source: You do NOT have to use `react-dom`, any JSX renderer will suffice. 
```tsx
import { LeafletMap, L } from "leaflet-react-fibers"
import ReactDOM from "react-dom"

const PopupInsideARectangle = () => {
  return (
    <LeafletMap options={{ crs: L.CRS.Simple }} jsxRenderer={ReactDOM.render}>
       <lfRectangle bounds={[[50, 50], [150, 100]]} options={{ fillColor: 'black' }} add={() => { console.log('added a rectangle layer') }}>
        <lfPopup latlng={[100, 100]} add={() => { console.log('added an popup layer') }}>
          <div>Hello world!</div>
        </lfPopup>
      </lfRectangle>
    </LeafletMap>
  )
}
```

## Similar work
None of the libraries mentioned below provide mutability control out of the box and state management features.
1. [react-leaflet-fiber](https://github.com/umar-ahmed/react-leaflet-fiber) another fiber implementation.
2. [react-leaflet](https://github.com/PaulLeCam/react-leaflet) react wrapper for leaflet which comes with hooks.

## Known Issues
[x] Mutability control does not work at the moment. This is a feature of this library that allows a layer to be explicitly mutable or immutable using a `mutable` prop.

## Development
Clone this repository and simply run `npm run storybook` to get started.

---
_Source: https://npm.io/package/leaflet-react-fibers · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
