 
 (defn- define-wdl []
   (js-invoke
-   (get-codemirror) "defineMode" "wdl"
+   @codemirror-instance "defineMode" "wdl"
    (fn []
      #js{:token (fn [stream]
                   (.eatSpace stream)

   (fn [{:keys [refs props locals]}]
     (let [{:keys [mode line-numbers? read-only? text]} props]
       (swap! locals assoc :code-mirror-instance
              ((get-codemirror) (react/find-dom-node (@refs "container"))
               (clj->js
                (merge
                 (when text {:value text})

          (not loaded?) [ScriptLoader
                         {:on-error #(swap! state assoc :error? true)
                          :on-load (fn []
                                     (when-not @codemirror-instance
                                       (reset! codemirror-instance (aget js/window "webpackDeps" "CodeMirror"))
                                       (define-wdl))
                                     (this :-display-code)
                                     (when-let [init (:initialize props)]
