https://github.com/samprof/reactsharp
C# library for building web user interfaces
https://github.com/samprof/reactsharp
Last synced: 11 months ago
JSON representation
C# library for building web user interfaces
- Host: GitHub
- URL: https://github.com/samprof/reactsharp
- Owner: SamProf
- License: mit
- Created: 2020-02-07T00:17:20.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-10-20T20:37:32.000Z (over 2 years ago)
- Last Synced: 2024-10-29T19:43:00.575Z (over 1 year ago)
- Language: C#
- Homepage: http://reactsharp.samprof.com/
- Size: 349 KB
- Stars: 40
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# React#
## ReactSharp - A C# library for building web user interfaces
## React alternative to Blazor
## Super Experimental - super unstable
[](https://www.nuget.org/packages/ReactSharp.Blazor/)
[](https://gitter.im/MatBlazor/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
[](https://github.com/SamProf/ReactSharp/stargazers)
[](https://github.com/SamProf/ReactSharp/issues)
[](https://reactsharp.samprof.com)
[](LICENSE)
[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=9XT68N2VKWTPE&source=url)
[](https://www.patreon.com/SamProf)
## Demo and Documentation
- [ReactSharp](http://reactsharp.samprof.com)
- [ReactSharp Todo](http://reactsharp.samprof.com/Todo)
## Examples
### Counter.cs
```csharp
public class Counter : ReactComponent
{
private int value = 0;
void Increment()
{
SetState(() => { value++; });
}
void Decrement()
{
SetState(() => { value--; });
}
public override object Render()
{
return new ReactElement($@"
Counter value: {value}
Increment
Decrement
");
}
}
```
### App.cs
```csharp
public class App : ReactComponent
{
public override object Render()
{
return new ReactElement($@"
");
}
}
```
### Index.razor
```html
@code
{
ReactElement _reactElement = new ReactElement($@"");
}
```
### Todo.cs [In action](http://reactsharp.samprof.com/Todo)
```csharp
public class Todo : ReactComponent
{
List items = Enumerable.Range(0, 10).Select(i => i.ToString()).ToList();
void Add()
{
SetState(() => { this.items.Add(Guid.NewGuid().ToString()); });
}
void Remove(string item)
{
SetState(() => { this.items.Remove(item); });
}
public override object Render()
{
return new ReactElement($@"
Todo: {items.Count}
Add item
{items.Select(i => new ReactElement($"Task - {i} X"))}
");
}
}
```
## News
### ReactSharp 1.0.0
- First public release
## Prerequisites
Don't know what Blazor is? Read [here](https://github.com/aspnet/Blazor)
Complete all Blazor dependencies.
- .NET Core 3.1
- Visual Studio 2019 with the ASP.NET and web development workload selected.
## Installation
Latest version in here: [](https://www.nuget.org/packages/ReactSharp.Blazor/)
To Install
```
Install-Package ReactSharp
Install-Package ReactSharp.Blazor
```
For client-side and server-side Blazor - add script section to index.html or _Host.cshtml (head section)
```html
```
## Questions
For *how-to* questions and other non-issues, for now you can use issues or you can use [](https://gitter.im/MatBlazor/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge).
## Contributing
We'd greatly appreciate any contribution you make. :)
## Sponsors & Backers
ReactSharp does not run under the umbrella of any company or anything like that.
It is an independent project created in spare time.
If you think that this project helped you or your company in any way, you can consider becoming a backer/sponsor.
- [PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=9XT68N2VKWTPE&source=url)
- [Patreon](https://www.patreon.com/SamProf)
## License
This project is licensed under the terms of the [MIT license](LICENSE).
## Thank you
- [Blazor](https://blazor.net)