Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save olivergeorge/4c450e514feac18503d8 to your computer and use it in GitHub Desktop.
Save olivergeorge/4c450e514feac18503d8 to your computer and use it in GitHub Desktop.
Quick hack attempt of using om components with reactjs.net prerendering

First issue was around using goog.require so I switched to a production build (advanced optimisations) build.

Second issue...

Visual studio reported errors trying to establish the virtual environment. It looks, perhaps, Google Closure was looking for features which would be available on a headless JS VM.

''' Error while loading "~/Content/ui/js/omapp.min.js": ReferenceError: XMLHttpRequest is not defined

at Script Document [6]:815:409 -> is.Wc=Math.max(0,k);this.Dg=h;this.send(b,c,d,Oi(e));return this};m=XMLHttpReq

'''

(ns prerenderables
(:require [om.core :as om :include-macros true]
[om.dom :as dom :include-macros true]
[sablono.core :as html :refer-macros [html]]))
(defn ^:export HelloWorld [props owner]
(om/component
(html [:div.HelloWorld "Hello" (:name props)])))
namespace MyApp
{
public static class ReactConfig
{
public static void Configure()
{
ReactSiteConfiguration.Configuration = new ReactSiteConfiguration()
.AddScript("~/Content/ui/js/omapp.min.js");
}
}
}
@Html.React("prerenderables.HelloWorld", new
{
name = "Daniel"
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment