# @gsmlg/react-redux-router

> react redux router

Latest version **0.2.10** (published 2018-06-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install @gsmlg/react-redux-router
pnpm add @gsmlg/react-redux-router
yarn add @gsmlg/react-redux-router
bun add @gsmlg/react-redux-router
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.10 |
| Published | 2018-06-04 |
| First published | 2018-05-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 81.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | gsmlg |

## Links

- npm: https://www.npmjs.com/package/@gsmlg/react-redux-router
- Repository: https://github.com/gsmlg/react-suit
- npm.io page: https://npm.io/package/@gsmlg/react-redux-router

## Recent versions

- 0.2.10 (latest) — 2018-06-04
- 0.2.9 — 2018-06-04
- 0.2.8 — 2018-06-01
- 0.2.7 — 2018-06-01
- 0.2.6 — 2018-05-30
- 0.2.5 — 2018-05-30
- 0.2.4 — 2018-05-30
- 0.2.3 — 2018-05-30
- 0.2.2 — 2018-05-29
- 0.2.0 — 2018-05-29
- 0.1.2 — 2018-05-28

## README

# React-Redux-Router

## RouteProvider
provide `router` context
``` javascript
      <Provider store={store}>
        <RouteProvider history={history}>
          <Switch>
            <Route path="/test" children={(...args) => { spy(args); return null; }} />
            <Redirect to="/test" />
          </Switch>
        </RouteProvider>
      </Provider>
```

## Switch
`Switch` only the first match child will be render
``` javascript
      <Provider store={store}>
        <RouteProvider history={history}>
          <Switch>
            <Route path="/test" children={(...args) => { spy(args); return null; }} />
            <Redirect to="/test" />
          </Switch>
        </RouteProvider>
      </Provider>

```

## Route
`path` if match path, then render `component` or `children`
``` javascript
      <Provider store={store}>
        <RouteProvider history={history}>
          <Switch>
            <Route path="/test" children={(...args) => { spy(args); return null; }} />
            <Redirect to="/test" />
          </Switch>
        </RouteProvider>
      </Provider>

```

## Redirect
* `from`: if match, redirct to `to`
* `to`: redirect to location 
``` javascript
      <Provider store={store}>
        <RouteProvider history={history}>
          <Switch>
            <Route path="/test" children={(...args) => { spy(args); return null; }} />
            <Redirect to="/test" />
          </Switch>
        </RouteProvider>
      </Provider>

```

## middleware

``` javascript
    history = createHistory(MEMO_MODE);
    store = createStore(
      combineReducers({router: routerReducer, spy: (st, act) => { reducerSpy(act); return {}; }}),
      applyMiddleware(routerMiddleware(history))
    );

```

## push

``` javascript
push.setDispatch(store.dispatch);
push('/users')
// or 
store.dispatch(push('/names'))
```

## Link

``` javascript
<Link to="/views" component={<Menu />} />
```

## routeReducer
route Reducer will produce location changes
**TODO** add `match` state in reducer
``` javascript
    history = createHistory(MEMO_MODE);
    store = createStore(
      combineReducers({router: routerReducer, spy: (st, act) => { reducerSpy(act); return {}; }}),
      applyMiddleware(routerMiddleware(history))
    );

```

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