Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/mattstypa/sillystore

Silly React Store
https://github.com/mattstypa/sillystore

Last synced: 18 days ago
JSON representation

Silly React Store

Awesome Lists containing this project

README

        

# SillyStore

This is just silly.

Seriously. Don't even look at this silly React store.

- No actions.
- No reducers.
- No mapping of props.

Connected components have a new prop.
- `store`: global state object.

```js
import { Store } from 'sillystore';

const initialStore = {
count: 0,
};

ReactDOM.render(


,
document.getElementById('root')
);
```

```js
import { connect, setStore } from 'sillystore';

class Count extends React.PureComponent {
increment = () => setStore({count: this.props.store.count + 1})

render() {
return (


Count: {this.props.store.count}


increment

);
}
}

export default connect(Count, ['count']);
```

## `connect(component, storeKeys);`
- `component` - React component.
- `storeKeys` - Array of store keys the component uses.