# raj-react

> React bindings for Raj

Latest version **0.0.7** (published 2018-06-23) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.7 |
| Published | 2018-06-23 |
| First published | 2017-09-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 7.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Author | Chris Andrejewski |
| Maintainers | andrejewski |
| Keywords | bindings, integration, raj, react |

## Links

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

## Dependencies (1)

- [raj](https://npm.io/package/raj.md) 1.0.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

- 0.0.7 (latest) — 2018-06-23
- 0.0.6 — 2018-06-17
- 0.0.5 — 2018-06-12
- 0.0.4 — 2017-09-16
- 0.0.3 — 2017-09-10
- 0.0.2 — 2017-09-10

## README

# Raj React
> React bindings for [Raj](https://github.com/andrejewski/raj)

```sh
npm install raj-react
```

[![npm](https://img.shields.io/npm/v/raj-react.svg)](https://www.npmjs.com/package/raj-react)
[![Build Status](https://travis-ci.org/andrejewski/raj-react.svg?branch=master)](https://travis-ci.org/andrejewski/raj-react)
[![Greenkeeper badge](https://badges.greenkeeper.io/andrejewski/raj-react.svg)](https://greenkeeper.io/)

## Usage

```js
import React from 'react'
import ReactDom from 'react-dom'
import {program} from 'raj-react'

const helloProgram = {
  init: [{text: 'Hello world'}],
  update (message, model) {
    return model
  },
  view (model, dispatch) {
    return <p>{model.text}</p>
  }
}

const App = program(React.Component, props => helloProgram)
const root = document.getElementById('app')
ReactDom.render(<App />, root)
```

## Documentation
`program(Component, props => ({init, update, view})): Component`
- `Component`: a React Component class
- `props`: the React component `props`
- `init`: the initial state and optional effect
- `update(message, state)`: return the new state and optional effect
- `view(state, dispatch)`: return the React view

The `raj-react` package exports a single function which takes a React component class and a function which receives the component's `props` and returns a Raj program `{init, update, view}` triplet; returns a React component.

### Questions

#### Where to use `raj-react`?
The `raj-react` package wraps the `raj` runtime and integrates within an existing React component tree. The root program is the entry point that meets the runtime. Most often, an app needs `raj-react` once. All child programs' `view` methods may return React components with no boilerplate required.

#### Does this work with React Native?
Yes, `raj-react` works with both web and React Native components. In the above example, `react-dom` renders a web page component.

#### Server-side rendering?
The `raj-react` package returns a React Component that works with [`ReactDOMServer`](https://facebook.github.io/react/docs/react-dom-server.html).

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