# nreact
**Repository Path**: ObjOne/nreact
## Basic Information
- **Project Name**: nreact
- **Description**: 一个C#/Xaml版的React库
- **Primary Language**: C#
- **License**: MIT
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2025-03-05
- **Last Updated**: 2025-03-11
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# NReact
React/Flux principles in C#/Xaml application. Experimental playground.
See various demos.
Please check official React/Flux resources to understand underlying concepts.
Implemented:
* Async Virtual Xaml (aka VirtualDOM) including complex patching mechanism (diff based on Keys) (NElement)
* Several Type Converters including enums, colors, brushes and resources (NConverters)
* Simple Flux Dispatcher (NDispatcher)
* Nuget Package including support for Store, WPF and Silverlight apps
* Key-based Diff-algorithm for Virtual Xaml (NPatch)
To to:
* Dynamic in-app CSX compilation using embeddable compiler (Mono.CSharp, Roslyn)
* Xaml-like Visual Studio CSX syntax transform including syntax highlighting and debugging.
* More type converters
Removed:
* CSX - C# syntax extension (aka React JSX). CSX -> C# transform MSBuild task and standalone executable (NReact.Csx). Removed due to poor debugging experience. New Roslyn-based approach needed.
* Dynamic typing for Component's Props and State (NDynamic). Removed due to poor performance of dynamics.
Existence questions:
* Why does one need NReact?
Final goal is to get something like this in Visual Studio/Roslyn/C#:
```javascript
using NReact;
class TodoList : NClass
{
public override NElement Render()
{
return { Children.Select((i, idx) => ) };
}
}
class TodoApp : NComponent
{
protected object[] Items { get; set; }
protected string Text { get; set; }
public override NElement Render()
{
var items = Items;
return
;
}
}
Application.Current.MainWindow.Render();
```
All this should compile to extension methods:
```
=> this.New()
=> this.New().Attr1("Value")
=> this.New().Attr1(Expression)
=> this.New().Attr1(Expression1).Attr2(Expression2)
=> this.New().Content(this.New())
```
Current syntax is yet more verbose:
```javascript
using NReact;
class TodoList : NClass
{
public override NElement Render()
{
return new NXaml().Children(Children.Select((i, idx) => new NXaml(idx).Text("* " + i)));
}
}
class TodoApp : NComponent
{
protected object[] Items { get { return GetState