You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/safe-from-scratch.md
+9-6Lines changed: 9 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,7 +32,7 @@ Now that we have basic core tools installed, we can go about creating a basic F#
32
32
```bash
33
33
dotnet new console -lang F#
34
34
```
35
-
* Reference the Giraffe NuGet package (if you wish to use Paket, feel free to install that tool at this point).
35
+
* Reference the **Giraffe** NuGet package (if you wish to use Paket, feel free to install that tool at this point).
36
36
* Create a basic Giraffe application to e.g. simply return the text "Hello world!" for every request.
37
37
* Run the application and confirm that it returns the expected text.
38
38
```bash
@@ -43,6 +43,9 @@ dotnet run
43
43
* Create a folder e.g. `client`.
44
44
* Create another plain F# console application in it.
45
45
* Add the Fable dotnet tool.
46
+
```bash
47
+
dotnet tool install fable
48
+
```
46
49
* To prove that Fable is installed, you should now be able to transpile the stock "Hello from F#" console app into JavaScript.
47
50
```bash
48
51
dotnet fable
@@ -52,7 +55,7 @@ dotnet fable
52
55
Now that we have a running HTTP server and the ability to create JS from F#, we can now install the required browser libraries and tools required to host a full app in the browser.
53
56
54
57
* Create an `index.html` file that will be used as the launch point for the web application; it will also load the JS that is generated by Fable.
55
-
* Install Vite with npm (install NPM and Node if you haven't already!).
58
+
* Install **Vite** with npm (install NPM and Node if you haven't already!).
56
59
```bash
57
60
npm install vite
58
61
```
@@ -91,22 +94,22 @@ We now spend the next few steps getting React working within the app and with F#
Now that we have a (very) basic F# client/server app, we'll now add support for React - a front-end framework that will enable us to create responsive and rich UIs.
93
96
94
-
* Add the `react` and `react-dom` packages to your NPM dependencies.
95
-
* Add the `@vitejs/plugin-react` and `remotedev` packages to your NPM dev dependencies.
97
+
* Add the **react** and **react-dom** packages to your NPM dependencies.
98
+
* Add the **@vitejs/plugin-react** and **remotedev** packages to your NPM dev dependencies.
96
99
* Add react to the list of plugins in your vite config.
Now that we have React added to our application, we can add the appropriate F# libraries such as Feliz to start to use React in a typesafe, F#-friendly manner.
100
103
101
-
* Add the Feliz NuGet package to the Client project.
104
+
* Add the **Feliz** NuGet package to the Client project.
102
105
* Remove the `<button>` element from the `index.html` - we'll be creating it dynamically with React from now on.
103
106
* Add an empty `<div>` with an named `id` to the body of the `index.html`. This will be the "root" element that React will attach to from which to make HTML elements.
104
107
* Using the Feliz React wrapper types, replace the contents of your `Program.fs` in the Client project so that it creates a React button that can behave as the original static HTML button.
105
108
106
109
### 3.3 [Add JSX support *(optional)*](https://github.com/CompositionalIT/safe-from-scratch/commit/78e4093502ec4b8281ec5c14f113e3ad14b4a6f6)
107
110
This next step adds Feliz's JSX support, which allows you to embed standard React JSX code directly in your F# applications.
108
111
109
-
* Add the Fable.Core and Feliz.Jsx.React NuGet packages to the Client project.
112
+
* Add the **Fable.Core** and **Feliz.Jsx.React** NuGet packages to the Client project.
110
113
* Instead of using the Feliz F# dialect for React components (such as the `button []` element), use standard JSX code with string interpolation.
111
114
* Reference `Program.jsx` instead of `Program.js`in your `index.html` file.
112
115
* Run the client application using the extra flag that instructs Fable to emit `.jsx` instead of `.js` files:
0 commit comments