# redux-container-state-globalstate

> Enables access to global state in a local container created by redux-container-state

Latest version **0.4.0** (published 2016-06-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install redux-container-state-globalstate
pnpm add redux-container-state-globalstate
yarn add redux-container-state-globalstate
bun add redux-container-state-globalstate
```

## 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.4.0 |
| Published | 2016-06-28 |
| First published | 2016-06-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=5.0.0 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Hans De Potter |
| Maintainers | hansdp |
| Keywords | redux, redux-elm, react-redux, elm, flux, global state, local state, container state |

## Links

- npm: https://www.npmjs.com/package/redux-container-state-globalstate
- Repository: https://github.com/HansDP/redux-container-state-globalstate
- Issues: https://github.com/HansDP/redux-container-state-globalstate/issues
- npm.io page: https://npm.io/package/redux-container-state-globalstate

## Dependencies (1)

- [react-redux](https://npm.io/package/react-redux.md) ^4.4.5

## Alternatives

- [@reckona/mreact-store](https://npm.io/package/@reckona/mreact-store.md) — 976 weekly downloads
- [regular-state](https://npm.io/package/regular-state.md) — 410 weekly downloads
- [@pacote/flux-actions](https://npm.io/package/@pacote/flux-actions.md) — 65 weekly downloads
- [@pilotlab/lux-debug](https://npm.io/package/@pilotlab/lux-debug.md) — 39 weekly downloads
- [vue-persist-state](https://npm.io/package/vue-persist-state.md) — 19 weekly downloads

## Recent versions

- 0.4.0 (latest) — 2016-06-28
- 0.3.1 — 2016-06-27
- 0.1.3 — 2016-06-24
- 0.1.2 — 2016-06-24

## README

# [redux-container-state-globalstate](https://github.com/HansDP/redux-container-state-globalstate)

**Note:** Work in progress. This project is not ready to be used

Provides a [redux-container-state](https://github.com/HansDP/redux-container-state) `view` enhancer that enables access to the Redux global state.

The concept of this enhancer is pretty straight forward: use the [connect](https://github.com/reactjs/react-redux/blob/master/docs/api.md#connectmapstatetoprops-mapdispatchtoprops-mergeprops-options) method of the [react-redux](https://github.com/reactjs/react-redux) package to connect global state into the view.

## Example usage

```javascript
import React from 'react'
import { compose } from 'redux'

import { view } from 'redux-container-state'
import globalStateEnhancer from 'redux-container-state-globalstate'

const mapStateToProps = (state) => {
  return {
    someGlobalSate: state.some.global.state
  }
}

const enhancedView = compose(globalStateEnhancer(mapStateToProps))(view)

export default enhancedView(({someGlobalState, ...restProperties}) => (
  <div>
    The global state is: { someGlobalState }
  </div>
))
```

### Global dispatch

Because your view can now use global state, it probably will need to dispatch global actions as well.

This can be achieved by requesting the `globalDispatch` property in your view.

```javascript
export default enhancedView(({someGlobalState, globalDispatch, ...restProperties}) => (
  <div>
    The global state is: { someGlobalState }
    <button onClick={ () => globalDispatch({ type: 'GLOBAL_TYPE'}) }>Dispatch something global</button>
  </div>
))
```

## Installation & Usage

You can install `redux-container-state-globalstate` via npm.

```
npm install redux-container-state-globalstate --save
```

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