I created this repo to learn how to use React hooks by using the dotnet new react
command.
The main things that I did after creating the project are:
- Update the file
ClientApp/package.json
to be the same as the latest version created by Create React App (currently usingreact-scripts
=2.1.3
). This includes updating everything and removing any unneeded scripts and dependencies. I also added the eslint hooks plugin to the package.json eslint config. - Moved the page components from
ClientApp/components
into a folderClientApp/pages/
- Re-wrote the component
ClientApp/pages/Counter
in a new hooks based componentClientApp/pages/CounterHooks
- Re-wrote the component
ClientApp/pages/FetchData
in a new hooks based componentClientApp/pages/FetchDataHooks
- Updated the navigation to link to these for comparison
To find out more about hooks start with the official react documentation: Hooks at a glance
- Dotnet Core SDK >= 2.2
- Node >=8
- Visual Studio 2017 OR
- Visual Studio Code AND C# extension for Visual Studio Code
You can run it from Visual Studio Code or the command line which will install all the NodeJS and Dotnet Core packages and then run both of them together.
You can run the project by opening it in Visual Studio Code and pressing F5.
Run the following from the root of the repository:
Note: You will need to also set the environment variable
ASPNETCORE_ENVIRONMENT
toDevelopment
on your machine. See here for Windows and here for MacOS
dotnet run
For more information see