Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spurious React key warnings if html macro chooses to interpret #57

Closed
dustingetz opened this issue Mar 19, 2015 · 13 comments
Closed

Spurious React key warnings if html macro chooses to interpret #57

dustingetz opened this issue Mar 19, 2015 · 13 comments

Comments

@dustingetz
Copy link

In this diff, the red version generates React key warnings, and the green version does not.

image

The html macro compile path does not generate warnings, but if the macro takes the interpreter path, it passes react an array rather than applying children as varargs.

@jmatsushita
Copy link

Got the same problem with [sablono "0.3.5-SNAPSHOT"]

@quetz
Copy link

quetz commented Feb 1, 2016

Got same problem with sablono 0.5.3 So it seems that contents of every let block must be wrapped with (html ...) and it's pretty inconvenient when writing rum components. Any progress on this issue?

@r0man
Copy link
Owner

r0man commented Feb 4, 2016

I added a test case for this issue over here #96, but can't reproduce the warning. Can someone provide a test case that does cause the warning?

@quetz
Copy link

quetz commented Feb 8, 2016

Is it possible to get cljs repl within project? And also run one testcase (like lein test :only ...)

@quetz
Copy link

quetz commented Feb 8, 2016

I'm complete clojure noob and was not able to assemble a test in sablono test suite, but here's minimal working example based on https://github.com/swannodette/mies template: https://github.com/quetz/sab57

To compile:

scripts/build

Then open index.html

@r0man
Copy link
Owner

r0man commented Feb 12, 2016

@quetz You can get a REPL by running lein figwheel. Devcards are then also available at http://localhost:3449

@currentoor
Copy link

I'm also getting this error. Does anyone have a workaround?

@r0man
Copy link
Owner

r0man commented Feb 14, 2016

@tonsky I'm trying to figure out what the problem is. Any idea why I can't macroexpand-1 this:

(require '[sablono.core :refer [html]])
(require '[rum.core :refer [defc]])

(macroexpand-1
 '(defc issue-57-rum [text]
    (html
     (let [text-add (str text " warning")]
       [:div
        [:h1 text]
        [:h1 text-add]]))))

I get the following error from parse-defc.

1. Unhandled java.lang.IllegalArgumentException
   Syntax error at ([text] (html (let [text-add (str text " warning")]
   [:div [:h1 text] [:h1 text-add]])))

                      REPL:   25  rum.core/parse-defc
                      REPL:    9  rum.core/parse-defc
                      REPL:   31  rum.core/-defc
                      REPL:   30  rum.core/-defc
                  core.clj:   54  rum.core/defc
                  core.clj:   41  rum.core/defc
               RestFn.java:  490  clojure.lang.RestFn/invoke
                  Var.java:  401  clojure.lang.Var/invoke
                  AFn.java:  171  clojure.lang.AFn/applyToHelper
                  Var.java:  700  clojure.lang.Var/applyTo
             Compiler.java: 6776  clojure.lang.Compiler/macroexpand1
                  core.clj: 3894  clojure.core/macroexpand-1
                  core.clj: 3888  clojure.core/macroexpand-1
                      REPL:    7  sablono.expand/eval29655
                      REPL:    7  sablono.expand/eval29655
             Compiler.java: 6927  clojure.lang.Compiler/eval
             Compiler.java: 6890  clojure.lang.Compiler/eval
                  core.clj: 3105  clojure.core/eval
                  core.clj: 3101  clojure.core/eval
                  main.clj:  240  clojure.main/repl/read-eval-print/fn
                  main.clj:  240  clojure.main/repl/read-eval-print
                  main.clj:  258  clojure.main/repl/fn
                  main.clj:  258  clojure.main/repl
                  main.clj:  174  clojure.main/repl
               RestFn.java: 1523  clojure.lang.RestFn/invoke
    interruptible_eval.clj:   87  clojure.tools.nrepl.middleware.interruptible-eval/evaluate/fn
                  AFn.java:  152  clojure.lang.AFn/applyToHelper
                  AFn.java:  144  clojure.lang.AFn/applyTo
                  core.clj:  646  clojure.core/apply
                  core.clj: 1881  clojure.core/with-bindings*
                  core.clj: 1881  clojure.core/with-bindings*
               RestFn.java:  425  clojure.lang.RestFn/invoke
    interruptible_eval.clj:   85  clojure.tools.nrepl.middleware.interruptible-eval/evaluate
    interruptible_eval.clj:   55  clojure.tools.nrepl.middleware.interruptible-eval/evaluate
    interruptible_eval.clj:  222  clojure.tools.nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
    interruptible_eval.clj:  190  clojure.tools.nrepl.middleware.interruptible-eval/run-next/fn
                  AFn.java:   22  clojure.lang.AFn/run
   ThreadPoolExecutor.java: 1142  java.util.concurrent.ThreadPoolExecutor/runWorker
   ThreadPoolExecutor.java:  617  java.util.concurrent.ThreadPoolExecutor$Worker/run
               Thread.java:  745  java.lang.Thread/run

@tonsky
Copy link
Contributor

tonsky commented Feb 14, 2016

No need to do do html inside sefc -- it's added by default by rum. Maybe that's the problem

-----Original Message-----
From: "r0man" [email protected]
Sent: ‎14.‎02.‎2016 17:46
To: "r0man/sablono" [email protected]
Cc: "Nikita Prokopov" [email protected]
Subject: Re: [sablono] Spurious React key warnings if html macro chooses tointerpret (#57)

@tonsky I'm trying to figure out what the problem is. Any idea why I can't macroexpand-1 this:
(require '[sablono.core :refer [html]])
(require '[rum.core :refer [defc]])

(macroexpand-1
'(defc issue-57-rum [text](html
%28let [text-add %28str text)]
[:div
[:h1 text]
[:h1 text-add]]))))I get the following error from parse-defc.

  1. Unhandled java.lang.IllegalArgumentException
    Syntax error at ([text](html %28let [text-add %28str text)]
    [:div [:h1 text] [:h1 text-add]])))
                  REPL:   25  rum.core/parse-defc
                  REPL:    9  rum.core/parse-defc
                  REPL:   31  rum.core/-defc
                  REPL:   30  rum.core/-defc
              core.clj:   54  rum.core/defc
              core.clj:   41  rum.core/defc
           RestFn.java:  490  clojure.lang.RestFn/invoke
              Var.java:  401  clojure.lang.Var/invoke
              AFn.java:  171  clojure.lang.AFn/applyToHelper
              Var.java:  700  clojure.lang.Var/applyTo
         Compiler.java: 6776  clojure.lang.Compiler/macroexpand1
              core.clj: 3894  clojure.core/macroexpand-1
              core.clj: 3888  clojure.core/macroexpand-1
                  REPL:    7  sablono.expand/eval29655
                  REPL:    7  sablono.expand/eval29655
         Compiler.java: 6927  clojure.lang.Compiler/eval
         Compiler.java: 6890  clojure.lang.Compiler/eval
              core.clj: 3105  clojure.core/eval
              core.clj: 3101  clojure.core/eval
              main.clj:  240  clojure.main/repl/read-eval-print/fn
              main.clj:  240  clojure.main/repl/read-eval-print
              main.clj:  258  clojure.main/repl/fn
              main.clj:  258  clojure.main/repl
              main.clj:  174  clojure.main/repl
           RestFn.java: 1523  clojure.lang.RestFn/invoke
interruptible_eval.clj:   87  clojure.tools.nrepl.middleware.interruptible-eval/evaluate/fn
              AFn.java:  152  clojure.lang.AFn/applyToHelper
              AFn.java:  144  clojure.lang.AFn/applyTo
              core.clj:  646  clojure.core/apply
              core.clj: 1881  clojure.core/with-bindings*
              core.clj: 1881  clojure.core/with-bindings*
           RestFn.java:  425  clojure.lang.RestFn/invoke
interruptible_eval.clj:   85  clojure.tools.nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj:   55  clojure.tools.nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj:  222  clojure.tools.nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
interruptible_eval.clj:  190  clojure.tools.nrepl.middleware.interruptible-eval/run-next/fn
              AFn.java:   22  clojure.lang.AFn/run

ThreadPoolExecutor.java: 1142 java.util.concurrent.ThreadPoolExecutor/runWorker
ThreadPoolExecutor.java: 617 java.util.concurrent.ThreadPoolExecutor$Worker/run
Thread.java: 745 java.lang.Thread/run

Reply to this email directly or view it on GitHub.

@r0man
Copy link
Owner

r0man commented Feb 14, 2016

@quetz I'm not sure but I think this is already fixed in master. Can you please try your example with sablono 0.6.0. I don't get the warning with the latest version.

@quetz
Copy link

quetz commented Feb 14, 2016

@tonsky, nope, removing html call would always result in warnings if there's a let block inside component. For example:

(rum/defc comp-ok [text]
  (let [text-add (str text " OK")]
    [:div
       [:h1 text]
       [:h1 text-add]
       ]))

Gives warning.

And this does not:

(rum/defc comp-ok [text]
  [:div
    [:h1 text]
    [:h1 text]
  ])

r0man added a commit that referenced this issue Feb 14, 2016
@quetz
Copy link

quetz commented Feb 14, 2016

@r0man, yeah it seems to be fixed in 0.6.0. Thanks alot!

@r0man
Copy link
Owner

r0man commented Feb 14, 2016

@quetz Ok, cool :)

@r0man r0man closed this as completed Feb 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants