lilactown / helix

A simple, easy to use library for React development in ClojureScript.
Eclipse Public License 2.0
631 stars 52 forks source link

Subst nil :value prop with empty string to avoid react error #43

Closed lucywang000 closed 4 years ago

lucywang000 commented 4 years ago
react_devtools_backend.js:6 Warning: `value` prop on `input` should not be null. Consider using an empty string to clear the component or `undefined` for uncontrolled components
lucywang000 commented 4 years ago

Just found this doesn't work ... The macro expand result is something like

(helix.impl.props/merge-obj
  (cljs.core/js-obj "className" "form-input"
                    "name" "user"
                    "value" value
                    "ref" ev/focus-on-render
                    "onChange" on-change))))

And the value of value is unknown when doing macro expand.

lucywang000 commented 4 years ago

okay, figured out the code path in the cljc. It shall work now.

lucywang000 commented 4 years ago

btw @Lokeh The cljc part is really mind-boggling, really hard to think about the code path. Have you though using macrovich to make it more maintainable?

lucywang000 commented 4 years ago

@Lokeh updated.

I agree, working in a cljc file is pretty difficult at first. For this, I don't think it's worth pulling in macrovich though. If at some point I decide it's worth trying to support self-hosted ClojureScript, then macrovich might be worth it 🤔

Makes sense. But personally I do feel the entangled reader conditionals really scary, especially when they calls into each other ... YMMV, though.