# wramp-react

> This is a package to use [Wramp](https://github.com/ryym/wramp) with [React](https://facebook.github.io/react/). This provides `createConnector` method that allows you to map a store state to a React component.

Latest version **0.1.1** (published 2017-02-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install wramp-react
pnpm add wramp-react
yarn add wramp-react
bun add wramp-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.1.1 |
| Published | 2017-02-11 |
| First published | 2017-02-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | ryym |
| Maintainers | ryym |

## Links

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

## Recent versions

- 0.1.1 (latest) — 2017-02-11
- 0.1.0 — 2017-02-11
- 0.0.2 — 2017-02-05
- 0.0.1 — 2017-02-05

## README

# Wramp React

This is a package to use [Wramp](https://github.com/ryym/wramp) with [React](https://facebook.github.io/react/).
This provides `createConnector` method that allows you to map a store state to a React component.

```javascript
// Create a function which connects a view to the given store.
const connect = createConnect(store)

const Counter = ({ title, count, increment }) => (
  <div>
    <h1>{title}</h1>
    <p>count</p>
    <button onClick={increment}>Increment</button>
  </div>
)

const CounterContainer = connect(Counter, {
  propsMapper: store => props => ({
    title: props.title,
    count: store.getCount(),
    increment: store.$increment,
  })
})

ReactDOM.render(
  <CounterContainer title="counter" />,
  document.getElementById('root')
)
```

## API

### `createConnector(store): connect`

This takes a store instance and generates a `connect` function.

### `connect(Component, config): Component`

This defines a React component that wraps a given component.
The generated component is updated whenever a store you pass to `createConnector` is updated.
You can specify how to map a state to its props by `config.propsMapper`.

#### `config.propsMapper: store => wrapperProps => props`

This need to return a function that creates props for the wrapped component.
The function is called whenever the store is updated,
and the wrapped component is re-rendered whenever the props are changed.

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