GithubHelp home page GithubHelp logo

garunaxper / react.net Goto Github PK

View Code? Open in Web Editor NEW

This project forked from reactjs/react.net

0.0 0.0 0.0 13.67 MB

.NET library for JSX compilation and server-side rendering of React components

Home Page: https://reactjs.net/

License: MIT License

CSS 4.06% HTML 2.20% Ruby 0.69% C# 87.81% PowerShell 0.32% JavaScript 4.08% ASP 0.04% Pascal 0.16% Batchfile 0.15% Shell 0.01% TypeScript 0.49%

react.net's Introduction

ReactJS.NET is a library that makes it easier to use Babel along with Facebook's React and JSX from C#.

Build status  NuGet version Download count

Features

Quick Start

Install the package

Install-Package React.Web.Mvc4 # For ASP.NET MVC 4 or 5
Install-Package React.AspNet   # For ASP.NET Core MVC

Install a Javascript engine and configure as the default (more info here on how this works)

Install-Package JavaScriptEngineSwitcher.V8
Install-Package JavaScriptEngineSwitcher.V8.Native.win-x64
public static class ReactConfig
{
    public static void Configure()
    {
        ReactSiteConfiguration.Configuration
            .AddScript("~/Content/HelloWorld.jsx");

        JsEngineSwitcher.Current.DefaultEngineName = V8JsEngine.EngineName;
        JsEngineSwitcher.Current.EngineFactories.AddV8();
    }
}

Create JSX files

// /Scripts/HelloWorld.jsx
const HelloWorld = props => {
	return <div>Hello {props.greeting}</div>;
};

Reference the JSX files from your HTML

<!-- Place this where you want the component div to render -->
@Html.React("HelloWorld", new { Greeting = "friends!" });

<!-- Place these at the end of the page -->
<script src="@Url.Content("~/Scripts/HelloWorld.jsx")"></script>
@Html.ReactInitJavaScript();

Now you can use the HelloWorld component.

For information on more advanced topics (including precompilation and server-side rendering), check out the documentation

Building Manually and Contributing

When building your own copy of ReactJS.NET (for example, if implementing a new feature or fixing a bug), your first build always needs to be done using the build script (dev-build.bat) as this generates a few files required by the build (such as SharedAssemblyVersionInfo.cs). Once this build is completed, you can open React.sln in Visual Studio and compile directly from Visual Studio. Please refer to the documentation page on contributing for more information on contributing to ReactJS.NET.

Note that the build requires you to have Git installed. If you do not want to install Git, you may remove the GitVersion task from build.proj.

react.net's People

Contributors

daniel15 avatar dustinsoftware avatar renovate-bot avatar renovate[bot] avatar taritsyn avatar rickbeerendonk avatar xabikos avatar alxandr avatar gunnim avatar radnor avatar shikigami avatar dependabot[bot] avatar daniilsokolyuk avatar awayken avatar saranshkataria avatar andersea avatar samppis avatar rosdi avatar vanillajonathan avatar teimaj avatar halstatt avatar coka avatar bartadv avatar alexinea avatar zpao avatar rarkins avatar ssaroiu avatar cheeseytoastie avatar suhailnaw avatar torbenrahbekkoch avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.