helix

https://github.com/Lokeh/helix
lilactown 2020-08-08T19:57:12.365200Z

heads up, I just changed my github name to lilactown

lilactown 2020-08-08T19:57:31.365700Z

if you're using git deps, I believe the URLs to repos should still work but they should be updated soon

jaime 2020-08-08T21:23:59.367800Z

Hello, what am I doing wrong here? I'm trying to get an array of map in the response body and display them. I can see the log of the response body, but not the console.log inside the for

(defnc list-view []
  (let [[state set-state] (hooks/use-state '())]
    (hooks/use-effect*
      :once
      (go (let [response (&lt;! (http/get "<http://localhost:9001/api/goals>"
                                       {:with-credentials? false}))]
            (println "RESPONSE BODY " (:body response))
            (set-state (:body response)))))

    ($ :div "List of goals")
    (for [goal state]
      (do (js/console.log "goal for " goal)
          ($ :div (:title goal))))))
console log
RESPONSE BODY  [{:description goal desc 1, :updated-at 2020-08-08T20:54:30Z, :installment-amount 1000, :target-date 2021-09-01T00:00:00Z, :title goal 1, :id 4fffed2e-9e7f-4b1a-a760-79b40a37cd27, :start-date 2020-08-01T00:00:00Z, :created-at 2020-08-08T20:54:30Z, :wallet-id 968d8164-b864-441f-804b-7ade37ce112f, :target-amount 13000} {:description goal desc 2, :updated-at 2020-08-08T20:54:30Z, :installment-amount 1000, :target-date 2021-09-01T00:00:00Z, :title goal 2, :id cdfc0783-899f-4ad0-aa64-e903702824cc, :start-date 2020-08-01T00:00:00Z, :created-at 2020-08-08T20:54:30Z, :wallet-id 968d8164-b864-441f-804b-7ade37ce112f, :target-amount 13000}]
console errors
Uncaught Error: [object Object] is not ISeqable
    at Object.cljs$core$seq [as seq] (core.cljs:1251)
    at Object.cljs$core$to_array [as to_array] (core.cljs:3662)
    at Function.eval [as cljs$core$IFn$_invoke$arity$2] (hooks.cljc:173)
    at limeray.web.route/list-view (route.cljs:94)
    at renderWithHooks (react-dom.development.js:16261)
    at beginWork$1 (react-dom.development.js:18795)
    at HTMLUnknownElement.callCallback (react-dom.development.js:337)
    at Object.invokeGuardedCallbackImpl (react-dom.development.js:386)
    at invokeGuardedCallback (react-dom.development.js:441)
    at beginWork$$1 (react-dom.development.js:25781)
The above error occurred in the &lt;limeray.web.route/list-view&gt; component:
    in limeray.web.route/list-view (created by <http://limeray.web.app/root|limeray.web.app/root>)
    in div (created by <http://limeray.web.app/root|limeray.web.app/root>)
    in <http://limeray.web.app/root|limeray.web.app/root>

Consider adding an error boundary to your tree to customize error handling behavior.
Visit <https://fb.me/react-error-boundaries> to learn more about error boundaries.
console warning
error when calling lifecycle function limeray.web.core/after-load Error: [object Object] is not ISeqable
    at Object.cljs$core$seq [as seq] (core.cljs:1251)
    at Object.cljs$core$to_array [as to_array] (core.cljs:3662)
    at Function.eval [as cljs$core$IFn$_invoke$arity$2] (hooks.cljc:173)
    at limeray.web.route/list-view (route.cljs:94)
    at renderWithHooks (react-dom.development.js:16261)
    at beginWork$1 (react-dom.development.js:18795)
    at HTMLUnknownElement.callCallback (react-dom.development.js:337)
    at Object.invokeGuardedCallbackImpl (react-dom.development.js:386)
    at invokeGuardedCallback (react-dom.development.js:441)
    at beginWork$$1 (react-dom.development.js:25781)

lilactown 2020-08-08T21:27:16.368600Z

hmm, well first thing I notice is you're use use-effect*. I think you'll want to use use-effect (no star) use-effect* should only be used for weird, advanced use-cases

jaime 2020-08-08T21:28:53.369900Z

Oh! I did not realized there is non-star one. It works! 🙂

lilactown 2020-08-08T21:28:59.370100Z

you'll notice that the docstring for use-effect* is different than use-effect:

(defn use-effect*
     "Like react/useEffect.  See `use-effect` for details on what `f`'s return values.  See namespace doc for `deps`.")

lilactown 2020-08-08T21:29:40.370900Z

([f])
([f deps])
are the aritys. the star version wants the arguments in the opposite order of the non-start one

lilactown 2020-08-08T21:29:59.371300Z

the error you're seeing is because it's trying to treat the function as a JS array 😓

jaime 2020-08-08T21:35:30.372900Z

Oh ok, just curious, does the error below tells that error you mentioned?

at Object.cljs$core$seq [as seq] (core.cljs:1251)
    at Object.cljs$core$to_array [as to_array] (core.cljs:3662)
    at Function.eval [as cljs$core$IFn$_invoke$arity$2] (hooks.cljc:173)
    at limeray.web.route/list-view (route.cljs:94)

lilactown 2020-08-08T21:39:06.373300Z

it made sense once I knew what the code of use-effect* looked like 😄

😄 1
lilactown 2020-08-08T21:39:42.374100Z

it doesn't tell me immediately what the issue was. but the use of use-effect* looked funny (as opposed to use-effect), and when I read the source of use-effect* it made sense

jaime 2020-08-08T21:44:11.376300Z

I wish the cljs error messages to be more helpful, I wonder how can I improve deciphering errors 😆 Btw, thanks a lot! Appreciate the prompt response

lilactown 2020-08-08T21:49:53.376600Z

sure thing! 🙇:skin-tone-2:

1