Fork me on GitHub
#biff
<
2024-04-24
>
Gabe Jensen12:04:58

Hello! I’m pretty new to the clojure web dev landscape, and biff is looking super promising! I was wondering how to properly reuse clojure functions to return common components, but not have to do “prop drilling” (eg passing data through several nested functions to a leaf level function that is reused everywhere). I come from react.js land and there’s the Context api that helps avoid a lot of the extra boilerplate that comes with prop drilling, but was wondering if I am missing some capability of biff or hiccup Any help would be appreciated!

Jacob O'Bryant15:04:52

welcome! I'm not super familiar with the context api other than having done a bit of googling, but I think the equivalent would be adding stuff to Biff's ctx map. ctx is generally passed down to all/most components anyway, so if you assoc things on to it (possibly with a namespace keyword to keep things organized) you typically won't have to do much extra work to then makes sure your leaf components have access to ctx.

🙌 1
Jacob O'Bryant15:04:40

a more principled but heavier approach would be to use https://pathom3.wsscode.com/ . your components can all become pathom resolvers and then query for what they need. pathom can take a bit to learn though and may be overkill in some cases. I'm planning to experiment with it + biff soon.

1
👍 1
Gabe Jensen14:04:24

That's super helpful. Thank you!

👌 1