# react-cursor

> Immutable state for React.js

Latest version **2.0.15** (published 2016-12-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-cursor
pnpm add react-cursor
yarn add react-cursor
bun add react-cursor
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.15 |
| Published | 2016-12-11 |
| First published | 2014-09-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1022 |
| Maintainers | dustingetz |
| Keywords | react, cursor, immutable, state, functional, flux |

## Links

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

## Dependencies (7)

- [update-in](https://npm.io/package/update-in.md) 0.0.1-alpha.5
- [lodash.omit](https://npm.io/package/lodash.omit.md) ^4.0.0
- [lodash.reduce](https://npm.io/package/lodash.reduce.md) ^4.0.0
- [lodash.isequal](https://npm.io/package/lodash.isequal.md) ^4.0.0
- [lodash.identity](https://npm.io/package/lodash.identity.md) ^3.0.0
- [lodash.isobject](https://npm.io/package/lodash.isobject.md) ^3.0.0
- [react-addons-update](https://npm.io/package/react-addons-update.md) ^0.14.2

## 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.15 (latest) — 2016-12-11
- 2.0.0-alpha.14 — 2016-05-20
- 2.0.0-alpha.13 — 2016-05-18
- 2.0.0-alpha.12 — 2016-01-31
- 2.0.0-alpha.11 — 2015-12-11
- 2.0.0-alpha.10 — 2015-12-09
- 2.0.0-alpha.9 — 2015-12-04
- 2.0.0-alpha.8 — 2015-12-01
- 2.0.0-alpha.7 — 2015-11-30
- 2.0.0-alpha.6 — 2015-11-30
- 2.0.0-alpha.5 — 2015-11-30
- 2.0.0-alpha.4 — 2015-11-20
- 2.0.0-alpha.3 — 2015-10-14
- 2.0.0-alpha.2 — 2015-10-14
- 2.0.0-alpha.1 — 2015-10-14
- … 7 more at https://npm.io/package/react-cursor/versions

## README

react-cursor
===============

> Immutable state for React.js

[react-cursor hello-world in a fiddle](https://jsfiddle.net/dustingetz/n9kfc17x/)

[![live demo](screenshot.png?raw=true)](http://demo-react-json-editor.s3-website-us-east-1.amazonaws.com/)

## What is react-cursor

Cursors are a tool for working with recursive or deeply nested data, immutably. react-cursor is a javascript port of an abstraction that I first saw in ClojureScript. Cursors let your app hold all its state at the root of the UI tree; thus the root is stateful, and all downtree views are stateless.

## Project Maturity

master is stable, there is a full test suite.

## API

`Cursor` interface has three methods: `value`, `swap` and `refine`.
 * `cur.value()` return the value in the cursor at some path.
 * `cur.refine(path, ...paths)` return a cursor nested inside another cursor
 * `cur.swap(f)` apply f to the value in the cursor value and puts returned value into the backing store

For frequently used swap functions, see the bundled `update-in` dependency: see [here](https://github.com/dustingetz/update-in). Cursor instances have optional syntax sugar for the swap fns provided by update-in; see [CursorOperations.js](https://github.com/dustingetz/react-cursor/blob/master/src/CursorOperations.js)

## FAQ
 * Cursors have value semantics, don't mutate values that come out of a cursor
 * Equal cursors are `===` for easy and efficient optimized rendering (see hello world jsfiddle for example)
 * You should read the source! The core cursor abstraction is 8 lines of code
 * There is an undocumented alternate implementation, `RefCursor`, which has reference semantics, this is only useful for working with legacy mutable code

## License

_`react-cursor` is governed under the MIT License._

## Attributions

react-cursor was built by Daniel Miladinov and Dustin Getz.

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