Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/team-griffin/redux-modal-router


https://github.com/team-griffin/redux-modal-router

modal react redux router

Last synced: about 2 months ago
JSON representation

Awesome Lists containing this project

README

        

# redux-modal-router

```sh
yarn add @team-griffin/redux-modal-router

npm i --save @team-griffin/redux-modal-router
```

## Usage
```jsx
import { ModalRoute } from '@team-griffin/redux-modal-router';

const openFoo = () => store.dispatch(signals.open({
route: 'FOO',
params: {
text: 'Hello World, I am FOO!',
},
}));

const openBar = () => store.dispatch(signals.open({
route: 'BAR',
}));

return (



(


{params.text}


)}/>

(

Hello World, I am BAR!


)}/>


Open FOO


Open BAR


);
```

## Setup

### Method 1 - As an isolated middleware
```jsx
import {
reducer as modalReducer,
middleware,
REDUCER_MOUNT_POINT,
} from '@team-griffin/redux-modal-router';

const reducer = combineReducers({
[REDUCER_MOUNT_POINT]: modalReducer,
});

const store = createStore(
reducer,
composeEnhancers(
applyMiddleware(
middleware,
),
)
);
```

### Method 2 - As an redux-most epic
```jsx
import {
reducer as modalReducer,
epic,
REDUCER_MOUNT_POINT,
} from '@team-griffin/redux-modal-router';

const epicMiddleware = createEpicMiddleware(combineEpics([
epic,
]));

const reducer = combineReducers({
[REDUCER_MOUNT_POINT]: modalReducer,
});

const store = createStore(
reducer,
composeEnhancers(
applyMiddleware(
epicMiddleware,
),
)
);
```