Best way to organize functions in React?

Hello everyone!

Question: What would be the best way to setup my functions associated to e.g. Mongodb Collection Objects? Are there Best Practices in React, Meteor?

I used to use the package Collection Helpers in blaze, where I could call Mongodb queries insight the method and everything was reactive.

Using this, in autorun, Messages AND Streams was both reactive.

Now in react, I have:

Bildschirmfoto 2024-02-12 um 15.30.15

I keep reactivity through the dep Array, but I could not use helper code like shopCart.getStream() as a inner Query to Collections.Streams.findOne(shopCart.stream_id) would not be reactive.

I found the Collection Helpers package really cool, because I could use code on both client and server side.

Do you know some cool patterns?

Thanks in advance :smiley:

Can you get the results of shopCart.getStream() and assign the results to a React component useState variable? That would make the React component reactive. (I haven’t used MongoDB except for Meteor Accounts.)