reagent-project / reagent-forms

Bootstrap form components for Reagent
339 stars 78 forks source link

Uncaught Error: No protocol method IDeref.-deref defined for type null: when trying to use the :visible? attribute #43

Closed eploko closed 9 years ago

eploko commented 9 years ago

I was trying to wrap my head around this issue for quite some time but couldn't find a solution.

When I add a visible? attribute to a field like this: [:div {:field :container :visible? #(if true true)}] ...all I get is the subject error in the console logs.

Any ideas on what may be wrong here or how this could be debugged further?

yogthos commented 9 years ago

The decision function has to take the document state as its parameter, eg:

[:div {:field :container :visible? #(:some-field %)}]
eploko commented 9 years ago

Thanks for the quick reply, but I kind of doubt that is the cause of the issue. In fact, I have tried the suggested variant before posting. It still bails out with the error.

There's another post on the net with the same problem as far as I can tell: https://groups.google.com/d/msg/reagent-project/tW1e-sUHZJ8/yk4I-VfvlyEJ And the sample given there follows your suggestion exactly, but it still fails: https://gist.github.com/kishanov/6b7fc1e959c2b1f660b2

I reckon it may have something to do with the version of reagent I'm using. I depend on 0.5.0-alpha3, while reagent-forms seems to favour 0.4.3.

The error comes from the line 6 in the src/reagent_forms/macros.clj file where it tries to deref the given doc atom. The thing is I'm quite new to Clojure/ClojureScript and I have neither an idea why the type is null there (as the error message suggests), nor why the reagent.core/atom may have no IDeref.-deref defined.

yogthos commented 9 years ago

Ok the code in the other example does look correct. I'll take a look at reproducing this with 0.5 branch.

yogthos commented 9 years ago

OK I got the problem reproduced, I'll have to investigate as to the root cause.

eploko commented 9 years ago

Thanks a ton for digging into this.

yogthos commented 9 years ago

Ok so found the issue, I added a wrapper for get/save! functions and lost the doc value in the opts in the process. I checked in a fix, and I'll push out a new release tonight.

yogthos commented 9 years ago

just pushed out a fix with [0.4.4], let me know if everything looks good

eploko commented 9 years ago

Yay! Works fine now. Thanks! :)