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/code-splitting.md
+8Lines changed: 8 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -84,6 +84,14 @@ First of all, under the hood `SplitRoute` uses **react-router**'s `Route` to mak
84
84
85
85
- By default, when you leave a split route, the CSS reference is removed from the document. You can pass in boolean `cacheCss` option to prevent it.
86
86
87
+
### Caveats
88
+
89
+
Here are some non-trivial points, that should be merged into the body of documentation above, but for now they are just mentioned here as points to remember:
90
+
91
+
- Although `<SplitRoute>` is technically a route, it is not quite possible to use it inside `<Switch>`, so in many cases you just have to use it as a usual component.
92
+
93
+
- If the chunk of code you split uses routing, you should use `<StaticRouter>` inside `renderServer` prop.
94
+
87
95
### Demo / Test
88
96
89
97
A simple demo / test of the code splitting is available at `/examples/code-splitting` endpoint of the app.
Copy file name to clipboardExpand all lines: docs/how-to-add-a-new-topcoder-community.md
+6-17Lines changed: 6 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -114,23 +114,12 @@ To add a new community with the name **demo**, we should follow the following pr
114
114
- `description`: A berief description which will be displayed in dashboard.
115
115
- `image`: A image that located at `/assets/images/tc-communities/background` will be displayed in dashboard
116
116
3. Custom pages of the community (anything beside `Challenges` and `Leaderboard`) should be created inside `/src/shared/components/tc-communities/communities/demo`. At the moment all communities have two custom pages: `Home` and `Learn`, you may just copy these from an existing community, and then customize to your particular needs.
117
-
4. Created custom pages should be registered inside `/src/shared/containers/tc-communities/Page/index.jsx`.
118
-
- First, import your custom pages into the file as
119
-
```js
120
-
import DemoHome from 'components/tc-communities/communities/demo/Home';
121
-
import DemoLearn from 'components/tc-communities/communities/demo/Learn';
122
-
```
123
-
- Second, add them into `renderCustomPage()` method. It includes a big `if-else` block, where you should add something similar to:
124
-
```js
125
-
} else if (communityId === 'demo') {
126
-
switch (pageId) {
127
-
case 'home': pageContent = <DemoHome />; break;
128
-
case 'learn': pageContent = <DemoLearn />; break;
129
-
default: break;
130
-
}
131
-
}
132
-
```
133
-
here the page IDs inside the switch statement should match the relative URLs you have configured inside `metadata.json` file (the address `.` is internally aliased to `home`, thus `home` pageId should be used to specify the page at the `.` route).
117
+
118
+
4. The routing inside community, and code splitting of the related code, should be set up inside `/src/shared/routes/Communities`:
119
+
- Copy/paste one of the existing community folders and rename it into `/src/shared/routes/Communities/Demo`;
120
+
- Inside `/src/shared/routes/Communities/Demo/index.jsx` you should change the name of code chunk in two places it is present (as value of `chunkName` prop, and inside `webpackChunkName` "magic comment");
121
+
- Inside `/src/shared/routes/Communities/Demo/Routes.jsx` you define necesary routing, as with usual `react-router` routing code;
122
+
- Finally, you link this routing code into `/src/shared/routes/Communities/Routes.jsx`.
134
123
135
124
5. At this point **demo** community is ready and accessible at the `/community/demo` route of the App (i.e., if we deploy dev version of the App to `community-west.topcoder-dev.com`, community will be accessible as `community-west.topcoder-dev.com/community/demo`).
0 commit comments