Skip to content

Instantly share code, notes, and snippets.

@kishanov
Created February 28, 2015 05:44
Show Gist options
  • Save kishanov/6b7fc1e959c2b1f660b2 to your computer and use it in GitHub Desktop.
Save kishanov/6b7fc1e959c2b1f660b2 to your computer and use it in GitHub Desktop.
This example throws "Uncaught Error: No protocol method IDeref.-deref defined for type null: " when used with reagent-forms 0.4.3
(ns forms-playground.core
(:require [reagent.core :as reagent :refer [atom]]
[reagent-forms.core :refer [bind-fields]]
[cljsjs.react :as react]))
(def form-template
[:form
[:div.checkbox
[:label
[:input {:type "checkbox" :field :checkbox :id :enable-details?}]]]
; expecting to make this group visible only if checkbox is checked.
[:div.form-group
{:field :container
:visible? #(:enable-details? %)} ; when :visible? is removed, there is no exception
[:input {:field :text :id :first-name}]
[:input {:field :text :id :last-name}]]])
(defn form []
(let [doc (atom {:enable-details? false})]
(fn []
[:div
[:div.page-header [:h1 "Reagent Form"]]
[bind-fields form-template doc]
[:label (str @doc)]])))
(defn main
[]
[:div.container
[form]])
(defn init! []
(reagent/render-component [main] (.getElementById js/document "app")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment