0

I'm very new to the cljs. I'm practicing the cljs with re-frame. I faced an issue to access a method of js instance.

(->> quill-contents
    (.parse js/JSON)
    (.setContents @editor))

If I tried to call .setContents of @editor which is the js instance wrapped with r/atom (actually, it is the Quill editor instance). Actually, this code works fine in dev mode, but it throws an error, such as xi(...).hi is not a function after making a release build.

I guess that .setContents is compiled to .hi in the release build, so it can't find the method from the js instance.

I'm using shadow-cljs to build this re-frame project.

How can I fix this issue?

mununki
  • 350
  • 4
  • 16

1 Answers1

2

It is due to lacking externs. Add ^js in front of @editor:

(->> quill-contents
    (.parse js/JSON)
    (.setContents ^js @editor))

It will automatically generate an extern for setContents in this case.

Eugene Pakhomov
  • 9,309
  • 3
  • 27
  • 53