Skip to content

v0.6.0

Pre-release
Pre-release
Compare
Choose a tag to compare
@gaearon gaearon released this 04 Jun 12:22
· 3955 commits to master since this release
  • Breaking change: stores now accepts an object, just like actions
  • Breaking change: Container children function signature is now ({ actions, state }) => ...
  • More fine-grained Container props validation

This fixes #22. There is no more prop shape difference between subscribing to a single or to many stores.
Your container may now look like this:

<Container stores={{ counter: stores.counterStore }}
           actions={{ increment, decrement }}>
  {({ state, actions }) => <Counter {...state} {...actions} />}
</Container>

Note that you can change the state shape by giving arbitrary keys to your stores. It's also easier to choose what exactly you want to pass to the component. For example, you could write actions={actions} instead of {...actions}, and get all actions in this.props.actions.

The decorator version is changed the same way:

@container({
  actions: { increment, decrement },
  stores: { counter: counterStore }
})
export default class Counter {

It also now accepts a second transformProps argument to be just as expressive as the component version:

@container({
  actions: { increment, decrement },
  stores: { counter: counterStore }
}, ({ actions, state}) => { ...actions, ...state })) // default shape; you can write your own