Skip to content

Commit abaf123

Browse files
authored
docs(Usage): update "CDN (no bundler)" section (#4221)
1 parent 32ca187 commit abaf123

File tree

1 file changed

+34
-12
lines changed

1 file changed

+34
-12
lines changed

docs/src/pages/Usage.mdx

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,40 @@ If you are using TypeScript, you don't need to install anything, typings are inc
4444

4545
### Option 2: CDN (no bundler)
4646

47-
This is the quickest way to get started, just add this link and script tag to the `<head>` of your `index.html` file.
47+
This is the quickest way to get started _however_ we still recommend to use
48+
[Create React App](https://create-react-app.dev/), [Next.js](https://nextjs.org/) or other preconfigured tooling.
49+
50+
Follow React's guide to prepare your enrivonment: [Add React in One Minute](https://reactjs.org/docs/add-react-to-a-website.html#add-react-in-one-minute).
51+
And then just add this link and script tag to the `<body>` after initializing React in your `index.html` file.
4852

4953
```html fitted label=index.html
50-
<link
51-
async
52-
rel="stylesheet"
53-
href="//cdn.jsdelivr.net/npm/semantic-ui@${props.versions.sui}/dist/semantic.min.css"
54-
/>
55-
<script
56-
async
57-
src="//cdn.jsdelivr.net/npm/semantic-ui@${props.versions.sui}/dist/semantic.min.js"
58-
></script>
54+
<body>
55+
<!-- ... other HTML ... -->
56+
<!-- ... Load React ... -->
57+
58+
<link
59+
async
60+
rel="stylesheet"
61+
href="https://cdn.jsdelivr.net/npm/semantic-ui@2/dist/semantic.min.css"
62+
/>
63+
<script src="https://cdn.jsdelivr.net/npm/semantic-ui-react/dist/umd/semantic-ui-react.min.js"></script>
64+
65+
<!-- Load our React component. -->
66+
<script src="like_button.js"></script>
67+
</body>
68+
```
69+
70+
```js label=like_button.js
71+
const e = React.createElement
72+
const { Button } = semanticUIReact
73+
74+
// ... Other JS code ...
75+
76+
const domContainer = document.querySelector('#like_button_container')
77+
78+
// 💡 This example is simplied to use React without JSX
79+
// https://reactjs.org/docs/react-without-jsx.html
80+
ReactDOM.render(e(Button, { primary: true }, 'Hello world!'), domContainer)
5981
```
6082

6183
## Custom themes
@@ -70,9 +92,9 @@ Semantic UI React is fully supported by all modern JavaScript bundlers.
7092

7193
Semantic UI React is fully compatible with `create-react-app` and works out the box. Setting up of custom theme is covered in [Theming guide](/theming).
7294

73-
### Webpack 4
95+
### Webpack 4/5
7496

75-
Semantic UI React is fully supported by Webpack 4. Please ensure that you build your app in [production mode](https://webpack.js.org/guides/production/) before release. Semantic UI React includes several optimizations in production mode, such as stripping `propTypes` from your build.
97+
Semantic UI React is fully supported by Webpack 4/5. Please ensure that you build your app in [production mode](https://webpack.js.org/guides/production/) before release. Semantic UI React includes several optimizations in production mode, such as stripping `propTypes` from your build.
7698

7799
## Examples
78100

0 commit comments

Comments
 (0)