Fork me on GitHub
#fulcro
<
2022-10-13
>
zhuxun204:10:58

Is there any Fulcro wrapper for React.memo(<Component>, <areEqual>)?

zhuxun204:10:42

Or any pattern that effectively achieves rendering based on selected prop fields?

zhuxun204:10:44

I could simply use (react/memo MyComponent are-equal?), but it's tricky to write are-equal? for a defsc component, as one need to know that all props are hoisted in a fulcro$props field, etc.

tony.kay17:10:31

It is not at all clear to me what your ultimate goal is. Are you trying to get shouldComponentUpdate for a hooks component?

tony.kay17:10:21

I’d have to play with it…just woke up and am too sleepy to invent the equivalent on the fly. are-equal? is trivial, and I think it should just work given the pattern in the React docs.

(defn are-equal? [^js a ^js b]
  (= (.-fulcro$value a) (.-fulcro$value b)))

tony.kay17:10:09

Note that this comparison can be expensive if the props are a large graph

tony.kay17:10:28

and then wrap the result in a normal fulcro factory?

tony.kay16:10:44

Curious if that worked for you?

zhuxun217:10:16

For my particular application, it is a small client-only component at the tip of the UI tree. So eventually I decided to skip defsc and use native react functions. But sure, I can give your suggestion a try.

zhuxun204:10:52

Is interop/hoc-factory what I need?

janezj08:10:19

In rad report controls I would like that checkbox label is aligned with other controls:

janezj08:10:15

So far I found only one way to put label above checkbox in a form: (sui/ui-form-field {} (dom/label "Test too?") (sui/ui-checkbox {:checked (or test-too false) :onChange #(m/toggle! this :ui/test-too)}))

tony.kay17:10:21

I made comments on that and the other PR you opened.