Skip to content

Commit 7abb89a

Browse files
committed
Add async component example
1 parent 35f7cf4 commit 7abb89a

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,27 @@ Heres a component rendered inline:
111111

112112
```
113113

114+
## Controlling JavaScript
115+
116+
You can pass simple props to components. However, if you need to write more advanced JavaScript, its recommended to declare it in the imports section.
117+
118+
```markdown
119+
---
120+
imports: |
121+
import { SomeComponent } from './SomeComponent';
122+
123+
const dynamic = () => import('./SomeComponent');
124+
125+
console.log('You can put anything here!');
126+
---
127+
128+
<SomeComponent simple="string" />
129+
<SomeComponent advanced={dynamic} />
130+
131+
```
132+
133+
Anything added to the `imports` front matter is added between the React import and component declaration in the outputted module.
134+
114135
## Syntax Highlighting
115136

116137
Syntax highlighting is done using PrismJS and is picked up automatically by tagging code blocks:

0 commit comments

Comments
 (0)