@@ -20,6 +20,7 @@ with an automatic JSX runtime.
20
20
* [ API] ( #api )
21
21
* [ ` toJsxRuntime(tree, options) ` ] ( #tojsxruntimetree-options )
22
22
* [ ` Options ` ] ( #options )
23
+ * [ ` Components ` ] ( #components-1 )
23
24
* [ ` Fragment ` ] ( #fragment-1 )
24
25
* [ ` Jsx ` ] ( #jsx-1 )
25
26
* [ ` JsxDev ` ] ( #jsxdev-1 )
@@ -143,6 +144,13 @@ Static JSX ([`Jsx`][jsx], required in production).
143
144
144
145
Development JSX ([ ` JsxDev ` ] [ jsxdev ] , required in development).
145
146
147
+ ###### ` components `
148
+
149
+ Components to use ([ ` Partial<Components> ` ] [ components ] , optional).
150
+
151
+ Each key is the name of an HTML (or SVG) element to override.
152
+ The value is the component to render instead.
153
+
146
154
###### ` development `
147
155
148
156
Whether to use ` jsxDEV ` when on or ` jsx ` and ` jsxs ` when off (` boolean ` ,
170
178
> Passing SVG might break but fragments of modern SVG should be fine.
171
179
> Use ` xast ` if you need to support SVG as XML.
172
180
181
+ ### ` Components `
182
+
183
+ Possible components to use (TypeScript type).
184
+
185
+ 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.
188
+
189
+ You can access props at ` JSX.IntrinsicElements ` .
190
+ For example, to find props for ` a ` , use ` JSX.IntrinsicElements['a'] ` .
191
+
192
+ ###### Type
193
+
194
+ ``` ts
195
+ type Components = {
196
+ [TagName in keyof JSX .IntrinsicElements ]:
197
+ | Component <JSX .IntrinsicElements [TagName ]>
198
+ | keyof JSX .IntrinsicElements
199
+ }
200
+
201
+ type Component <ComponentProps > =
202
+ // Function component:
203
+ | ((props : ComponentProps ) => JSX .Element | string | null | undefined )
204
+ // Class component:
205
+ | (new (props : ComponentProps ) => JSX .ElementClass )
206
+ ` ` `
207
+
173
208
### ` Fragment `
174
209
175
210
Represent the children, typically a symbol (TypeScript type).
@@ -348,9 +383,9 @@ followed by browsers such as Chrome, Firefox, and Safari.
348
383
## Types
349
384
350
385
This package is fully typed with [ TypeScript] [ ] .
351
- It exports the additional types [ ` Fragment ` ] [ fragment ] , [ ` Jsx ` ] [ jsx ] ,
352
- [ ` JsxDev ` ] [ jsxdev ] , [ ` Options ` ] [ options ] , [ ` Props ` ] [ props ] , [ ` Source ` ] [ source ] ,
353
- and [ ` Space ` ] [ Space ] .
386
+ It exports the additional types [ ` Components ` ] [ components ] ,
387
+ [ ` Fragment ` ] [ fragment ] , [ ` Jsx ` ] [ jsx ] , [ ` JsxDev ` ] [ jsxdev ] , [ ` Options ` ] [ options ] ,
388
+ [ ` Props ` ] [ props ] , [ ` Source ` ] [ source ] , and [ ` Space ` ] [ Space ] .
354
389
355
390
The function ` toJsxRuntime ` returns a ` JSX.Element ` , which means that the JSX
356
391
namespace has to by typed.
@@ -463,3 +498,5 @@ abide by its terms.
463
498
[ source ] : #source
464
499
465
500
[ space ] : #space-1
501
+
502
+ [ components ] : #components-1
0 commit comments