-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨ Add Support for React #872
Conversation
@jasontaylordev Thank you very much for this. I am using React Native with your .NET template right now. I use codegen-openapi-generator to generate typescript files for my React Native app. It creates a TypeScript service that utilizes Redux Tookit. Very similar to NSwag, and could also be added to the .csproj targets if the template user wanted to generate React Native client code. In my current implementation of your architecture I have a folder called ClientApps that contains several submodule repositories. An Angular App, and a React Native mobile app. Since I have an Angular app and a React Native app, I use NSwag to generate the Angular HttpClient code, and Redux-Toolkit-CodeGen-OpenApi to generate the React Native client code. I love setting up Git submodules for each CilentApp so they are still connected to the API in the folder hierarchy and can receive the generated http client code, but are independently maintained on Github and have their own repo to execute their own Github actions. I like to use Azure Static Apps for the Angular Client, Azure App Services to host the API, and Expo to host the React Native App. Thus, I need 3 GitHub Actions to deploy when PRs are merged, it just makes it easier if they are 3 different repos that have their own PR's, actions, and version history. |
Hey @nickgallimoresoftware that sounds like an awesome project! Thanks for the overview and keep up the good work. 😀 |
@nickgallimoresoftware do you have an example of your react native app + this template? :) |
What I did was added a package.json to WebUI, then edited the csproj to install and run this code generation package from Redux Tool Kit: https://redux-toolkit.js.org/rtk-query/usage/code-generation Package.json
Then added npm install and run events to the WebUI.csproj. Note I also run the Angular one as well simultaneously. This way I auto update my Angular App's HttpClient calls, and my React Native's Redux Tookit Queries simultaneously when making changes to the API. I also have my ClientApps setup as Git Submodules rather than being apart of the same repo. WebUI.csproj
nswag.json
|
@nickgallimoresoftware Thank you! |
I had same idea, until I realized react native web doesn't support very many libraries and I haven't been able to get it to work. One day. All you have to do is not use nswag. Remove the target group from WebUI.csproj and don't use the nswag.json. |
Overview
Since its creation, the template has only supported Angular. With these changes, the template now supports React and Angular.
Changes Made
Example
You can create a new project using one of the following commands:
dotnet new ca-sln --clientFramework angular
dotnet new ca-sln --clientFramework react
If you do not specify a client framework, it will default to Angular.
Please review the changes and provide your feedback. Thank you! ❤️