Yomguithereal/baobab-react

Branch decorator question

vcardins opened this issue · 8 comments

I'm trying

@branch({user: ['user', 'model']})

to get an user sub collection but it returns undefined. This works fine:

state.select(['user', 'model']).get())

What am I doing wrong?

Hello @vcardins. Without more context it's quite hard to answer your question. Is your code available somewhere?

Thanks for the prompt response. Maybe a screenshot is worth a thousand words
image
I use baobab in another project (mixim) and I'm able to do something like

...
cursors: {
	models: ['lookup', 'models'],
}

If still unclear, I can create a gist.
Thank you very much !

Yes, a gist would be nice. With what you wrote, this.props.lookup, for instance, should be the data at the defined cursor not a cursor itself.

Sorry, I haven't touched this project for last few days. So, please see here my gist: https://gist.github.com/vcardins/f7ddfc91039b40c18eff447441a5be46.
Thank you much for the support.

Did you correctly root your main component to the tree? What does your state file looks like?

Hey, I just updated gist, please take a look. Basically, is it possible to get model data with something like:

@branch({user: ['user', 'model']})

My goal by using the HOC, have access to nested cursors data. Apologies if I'm misunderstanding something, I'm just starting with Baobab.

Well might be that your user object is empty or that your delaying the .commit is too late and a render without data happen before.

It was an implementation mistake, it's working fine now. Closing ticket