Skip to content

Basic Usage

Roman M. Yagodin edited this page Jun 23, 2017 · 5 revisions

DRAFT

Module configuration

// ReactConfig.cs

using R7.Dnn.Extensions.React;
using WebActivatorEx;

[assembly: WebActivatorEx.PreApplicationStartMethod (typeof (YourModule.React.ReactConfig), "Configure")]

namespace YourModule.React
{
    public static class ReactConfig
    {
        public static void Configure ()
        {
            DnnReact.AddScriptWithoutTransform ("~/DesktopModules/MVC/YourModule/js/lib/bundle.js");

            DnnReact.AddScriptsWithoutTransform (
                "~/DesktopModules/MVC/YourModule/js/lib/Component1.js",
                "~/DesktopModules/MVC/YourModule/js/lib/Component2.js"
            );
        }
    }
}

Basic usage in MVC

@inherits DotNetNuke.Web.Mvc.Framework.DnnWebViewPage<MiniGalleryViewModel>

@using DotNetNuke.Web.Mvc.Helpers
@using DotNetNuke.Web.Client.ClientResourceManagement
@using DotNetNuke.Framework.JavaScriptLibraries
@using R7.Dnn.Extensions.React

@{
    JavaScript.RequestRegistration ("React");
    JavaScript.RequestRegistration ("ReactDOM");
    ClientResourceManager.RegisterScript (Dnn.DnnPage, "~/DesktopModules/MVC/YourModule/js/lib/Hello.js");
}

@Dnn.ReactWithInit("Hello", new {
    name = "John Doe"
})

Basic usage in WebForms

<%@ Register TagPrefix="dnn" TagName="JavaScriptLibraryInclude" Src="~/admin/Skins/JavaScriptLibraryInclude.ascx" %>
<%@ Register TagPrefix="dnn" Namespace="DotNetNuke.Web.Client.ClientResourceManagement" Assembly="DotNetNuke.Web.Client" %>
<%@ Import Namespace="R7.Dnn.Extensions.React" %>

<dnn:JavaScriptLibraryInclude runat="server" Name="React" />
<dnn:JavaScriptLibraryInclude runat="server" Name="ReactDOM" />
<dnn:DnnJsInclude runat="server" FilePath="~/DesktopModules/MVC/YourModule/js/lib/Hello.js" />

<%= DnnReact.ReactWithInit ("Hello", new { name = "John Doe" }) %>
Clone this wiki locally