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
> :information_source: This re-initializes the repo and sets up your NPM project.
32
+
33
+
21
34
**3. Install the dependencies:**
22
35
23
36
```sh
24
37
npm install
25
38
```
26
39
40
+
> You're done installing! Now let's get started developing.
41
+
42
+
43
+
44
+
## Development Workflow
45
+
46
+
27
47
**4. Start a live-reload development server:**
28
48
29
49
```sh
30
50
PORT=8080 npm run dev
31
51
```
32
52
53
+
> This is a full web server nicely suited to your project. Any time you make changes within the `src` directory, it will rebuild and even refresh your browser.
54
+
55
+
33
56
**5. Generate a production build in `./build`:**
34
57
35
58
```sh
36
59
npm run build
37
60
```
38
61
62
+
You can now deploy the contents of the `build` directory to production!
63
+
64
+
> **Example:** deploy to [surge.sh](https://surge.sh):
65
+
>
66
+
> `surge ./build -d my-app.surge.sh`
67
+
68
+
69
+
---
70
+
71
+
72
+
## Structure
73
+
74
+
Apps are built up from simple units of functionality called Components. A Component is responsible for rendering a small part of an application, given some input data called `props`, generally passed in as attributes in JSX. A component can be as simple as:
75
+
76
+
```js
77
+
classLinkextendsComponent {
78
+
render({ to, children }) {
79
+
return<a href={ to }>{ children }</a>;
80
+
}
81
+
}
82
+
// usage:
83
+
<Link to="/">Home</Link>
84
+
```
85
+
86
+
87
+
88
+
## Handling URLS
89
+
90
+
:information_desk_person: This project contains a basic two-page app with [URL routing](http://git.io/preact-router).
91
+
92
+
Pages are just regular components that get mounted when you navigate to a certain URL. Any URL parameters get passed to the component as `props`.
93
+
94
+
Defining what component(s) to load for a given URL is easy and declarative. You can even mix-and-match URL parameters and normal props.
0 commit comments