Yomguithereal / baobab-react

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

Branch decorator question #122

Closed vcardins closed 7 years ago

vcardins commented 7 years ago

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?

Yomguithereal commented 7 years ago

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

vcardins commented 7 years ago

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 !

Yomguithereal commented 7 years ago

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.

vcardins commented 7 years ago

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.

Yomguithereal commented 7 years ago

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

vcardins commented 7 years ago

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.

Yomguithereal commented 7 years ago

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.

vcardins commented 7 years ago

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