Yomguithereal / baobab-react

React integration for Baobab.
MIT License
309 stars 38 forks source link

Any 1.x to 2.x differences guide yet? #103

Open srcspider opened 8 years ago

Yomguithereal commented 8 years ago

Allow @srcspider. I haven't had time to write such a guide, but the differences are quite few: Just know that the higher-order function has seen its arguments swapped, that you don't have to provide an object with the cursors and actions key, but just the cursors and that a dispatch props is passed to the component as a mean to dispatch the actions.

Zache commented 8 years ago

While I've basically never used it actions used bind to set the tree as this, this no longer happens with dispatch. I'm curious as to if there is any reason for this change?

Yomguithereal commented 8 years ago

The reasons are the following:

psypersky commented 8 years ago

I used to use async actions as

this.props.actions.sendMessage(text)
.then((res) => this.setState({ sendingMessage: false }));

I guess this will force me to send all the state to the tree instead of leaving some state in the components

Yomguithereal commented 8 years ago

It's a bit strange to have a component with mixed local & external state but I see your point. Maybe I can make the dispatch function return the result of you action so you can access your Promise.