# @jetbrains/kotlin-react-redux

> Kotlin wrapper for React Redux library

Latest version **5.0.7-pre.91** (published 2020-02-05) · Apache-2-0 license · 0 weekly downloads

## Install

```sh
npm install @jetbrains/kotlin-react-redux
pnpm add @jetbrains/kotlin-react-redux
yarn add @jetbrains/kotlin-react-redux
bun add @jetbrains/kotlin-react-redux
```

## Health

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

Positive: no vulnerabilities; high maintenance score.

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

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 5.0.7-pre.91 |
| Published | 2020-02-05 |
| First published | 2018-08-19 |
| Weekly downloads | 0 |
| License | Apache-2-0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 464.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1594 |
| Author | Aidan Heller |
| Maintainers | allvo, bashor, jetbrains-admin, jetbrains-buildserver, kisenka, kotlin, maksimr, princed |

## Links

- npm: https://www.npmjs.com/package/@jetbrains/kotlin-react-redux
- Repository: https://github.com/JetBrains/kotlin-wrappers
- Homepage: https://github.com/JetBrains/kotlin-wrappers#readme
- Issues: https://github.com/JetBrains/kotlin-wrappers/issues
- npm.io page: https://npm.io/package/@jetbrains/kotlin-react-redux

## Recent versions

- 5.0.7-pre.91 (latest) — 2020-02-05
- 5.0.7-pre.89 — 2019-12-12
- 5.0.7-pre.83 — 2019-09-25
- 5.0.7-pre.82 — 2019-08-09
- 5.0.7-pre.80 — 2019-07-22
- 5.0.7-pre.67 — 2019-01-23
- 5.0.7-pre.61 — 2018-12-05
- 5.0.7-pre.60 — 2018-12-05
- 5.0.7-pre.58 — 2018-10-30
- 5.0.7-pre.56 — 2018-10-17
- 5.0.7-pre.55 — 2018-10-05
- 5.0.7-pre.54 — 2018-09-14
- 5.0.7-pre.53 — 2018-09-13
- 5.0.7-pre.52 — 2018-09-12
- 5.0.7-pre.49 — 2018-08-22
- … 1 more at https://npm.io/package/@jetbrains/kotlin-react-redux/versions

## README

## kotlin-react-redux

Kotlin wrapper for React Redux library. Major version number of this wrapper matches that of React Redux itself.

### Installation

1. `npm i @jetbrains/kotlin-react-redux`

2. `npm run gen-idea-libs`

See the [Bintray page](https://bintray.com/kotlin/kotlin-js-wrappers/kotlin-react-redux) for Maven and Gradle 
installation instructions.

### Usage

Using the provider is just like in JavaScript:

```kotlin
provider(store) {
    app()
}
```

However, you may want to use `rConnect` to connect your components, because it allows you to use 
type-safe builders instead of returning props objects. If you would like to just use `connect` as usual,
you can do that too:

```kotlin
val connectedComponent: RClass<ConnectedComponentProps> =
    rConnect<State, RAction, WrapperAction, ConnectedComponentProps, StateProps, DispatchProps, WrappedComponentProps>(
        { state, props ->
            prop1 = state.prop1
            // ...
        }, { dispatch, props ->
        eventHandler1 = { dispatch(SomeAction()) }
        // ...
    }
    )(WrappedComponent::class.rClass)

// ...

class ParentComponent : RComponent {
    override fun RBuilder.render() {
        connectedComponent {}
    }
}
```

### rConnect Type Parameters

```
interface WrappedComponentProps : RProps {
    var prop1: Int?
    var eventHandler1: (someValue: Int?) -> Unit
}

internal interface StateProps : RProps {
    var prop1: Int?
}

internal interface DispatchProps : RProps {
    var eventHandler1: (someValue: Int?) -> Unit
}

class WrappedComponent(props: WrappedComponentProps) : RComponent<WrappedComponentProps, RState>(props) {
    // ...
}

private val mapStateToProps: StateProps.(AppState, WrappedComponentProps) -> Unit = { state, props ->
    prop1 = state.prop1
}

private val mapDispatchToProps: DispatchProps.((RAction) -> WrapperAction, WrappedComponentProps) -> Unit = { dispatch, props ->
    eventHandler1 = { dispatch(SomeAction()) }
}
```

### Tutorial

See [lawik123/kotlin-poc-frontend-react-redux](https://github.com/lawik123/kotlin-poc-frontend-react-redux).
This project is an implementation/translation of the react-redux [Todo List example project](https://redux.js.org/basics/example) in Kotlin (with the addition of react-router).

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