-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Accessing cursors in component #112
Comments
This was removed to enforce architectural good practices and to boost performance. You are now required to use actions to edit the tree. |
Was searching on this for a little while; Would be good to have a section on differences between 1.x and 2.x outlining the major changes.
|
@Yomguithereal Could you elaborate on the performance aspect? Is the not performant to pass cursors around as props? |
You should avoid to create too many cursors (say, creating one cursor per element of a long list is not advisable). Because even if they are cached as singleton per path, you still register some listeners and observers.
This is not really an issue but I don't really see why you would like to do that. In my experience, components just want to consume data from your tree and trigger some actions but not having control over the underlying cursors. In this regard it's actually quite similar to redux etc. |
So, let's say:
Then anytime, I call Although, if some child component wants to modify data up the tree (any data not passed to it as a prop), then yes, I'd need to trigger some actions.) |
Sure. But this is more or less what the baobab-react helpers handle for you. |
The problem I ran into with For example, if we look at Redux seems handles that by reducer composition ( Is there a better way to handle that in baobab-react ? |
Usually, I do the following: I often split my action files hierarchically and they all have sets of cursor paths that the actions can use. Or I use function composition to abstract this issue. Another solution is to pass the paths as the actions' arguments but I am not so found of this. Redux is already more abstract and indeed handle this somewhat using |
In version 1.x we could access cursor instance via
this.cursors
. Now, it was removed from the documentation. Why?And how to access to cursor instance when we use HoC?
The text was updated successfully, but these errors were encountered: