Fork me on GitHub
#reagent
<
2022-12-02
>
Sam Ritchie20:12:55

Just released a reagent component for interactive equation editing, thought it might be interesting here! https://clojurians.slack.com/archives/C06MAR553/p1670012763440319

Sam Ritchie23:12:12

hey all - is there some way to pass a vector as a child to a React component? I am getting Uncaught Error: Assert failed: Invalid Hiccup form: [-1 1]

Apple23:12:59

[-1 1] is wrong.

Sam Ritchie23:12:32

@UP82LQR9N haha, can you be more specific?

Sam Ritchie23:12:38

I am passing a pair of coordinates to a Point component

Sam Ritchie23:12:19

;; this works fine:
(defn Point [opts coords]
  ...)

[Point {:name "A" :size 4}
 [-1 1]]

Apple23:12:20

it's usually [:div "xyz" "-1" "1"]

Sam Ritchie23:12:54

strings won’t work, these are floating point coordinates of a point

Apple23:12:55

oh i see what you are saying

Sam Ritchie23:12:56

(def Point
  (re/adapt-react-class
   (react/forwardRef
    (fn [props ref]
      ...))))

[Point {:name "A" :size 4}
 [-1 1]]

Sam Ritchie23:12:04

this fails before the inner function is ever called with that error

Apple23:12:28

does '(-1 1) work? i dnot know how to solve this.

Sam Ritchie23:12:17

I have an idea…

Sam Ritchie23:12:01

I think if I really need to do this i can make an outer component that takes the vector and stuffs it into props under some key like :coords , then returns [InnerPoint {:coords …}]