@@ -144,25 +144,29 @@ Static JSX ([`Jsx`][jsx], required in production).
144
144
145
145
Development JSX ([ ` JsxDev ` ] [ jsxdev ] , required in development).
146
146
147
+ ###### ` development `
148
+
149
+ Whether to use ` jsxDEV ` when on or ` jsx ` and ` jsxs ` when off (` boolean ` ,
150
+ default: ` false ` ).
151
+
147
152
###### ` components `
148
153
149
154
Components to use ([ ` Partial<Components> ` ] [ components ] , optional).
150
155
151
156
Each key is the name of an HTML (or SVG) element to override.
152
157
The value is the component to render instead.
153
158
154
- ###### ` development `
155
-
156
- Whether to use ` jsxDEV ` when on or ` jsx ` and ` jsxs ` when off (` boolean ` ,
157
- default: ` false ` ).
158
-
159
159
###### ` filePath `
160
160
161
161
File path to the original source file (` string ` , optional).
162
162
163
163
Passed in source info to ` jsxDEV ` when using the automatic runtime with
164
164
` development: true ` .
165
165
166
+ ###### ` passNode `
167
+
168
+ Pass the hast element node to components (` boolean ` , default: ` false ` ).
169
+
166
170
###### ` space `
167
171
168
172
Whether ` tree ` is in the ` 'html' ` or ` 'svg' ` space ([ ` Space ` ] [ space ] , default:
@@ -183,21 +187,25 @@ it.
183
187
Possible components to use (TypeScript type).
184
188
185
189
Each key is a tag name typed in ` JSX.IntrinsicElements ` .
186
- Each value is a component accepting the corresponding props or a different tag
187
- name .
190
+ Each value is either a different tag name, or a component accepting the
191
+ corresponding props (and an optional ` node ` prop if ` passNode ` is on) .
188
192
189
193
You can access props at ` JSX.IntrinsicElements ` .
190
194
For example, to find props for ` a ` , use ` JSX.IntrinsicElements['a'] ` .
191
195
192
196
###### Type
193
197
194
198
``` ts
199
+ import type {Element } from ' hast'
200
+
195
201
type Components = {
196
202
[TagName in keyof JSX .IntrinsicElements ]:
197
- | Component <JSX .IntrinsicElements [TagName ]>
203
+ | Component <JSX .IntrinsicElements [TagName ] & ExtraProps >
198
204
| keyof JSX .IntrinsicElements
199
205
}
200
206
207
+ type ExtraProps = {node? : Element | undefined }
208
+
201
209
type Component <ComponentProps > =
202
210
// Function component:
203
211
| ((props : ComponentProps ) => JSX .Element | string | null | undefined )
@@ -222,7 +230,7 @@ Create a production element (TypeScript type).
222
230
###### Parameters
223
231
224
232
* ` type ` ( ` unknown ` )
225
- — element type: the ` Fragment ` symbol or a tag name ( ` string ` )
233
+ — element type: ` Fragment ` symbol, tag name ( ` string ` ), component
226
234
* ` props ` ([ ` Props ` ][props])
227
235
— element props and also includes ` children `
228
236
* ` key ` ( ` string ` or ` undefined ` )
@@ -239,7 +247,7 @@ Create a development element (TypeScript type).
239
247
###### Parameters
240
248
241
249
* ` type ` ( ` unknown ` )
242
- — element type: the ` Fragment ` symbol or a tag name ( ` string ` )
250
+ — element type: ` Fragment ` symbol, tag name ( ` string ` ), component
243
251
* ` props ` ([ ` Props ` ][props])
244
252
— element props and also includes ` children `
245
253
* ` key ` ( ` string ` or ` undefined ` )
0 commit comments