@@ -36,6 +36,7 @@ interface ConfigInterface {
3636 receiveLabel? : string ;
3737 requestLabel? : string ;
3838 replyLabel? : string ;
39+ extensions? : Record <string , React .ComponentType <ExtensionComponentProps >>;
3940}
4041```
4142
@@ -100,6 +101,11 @@ interface ConfigInterface {
100101 This field contains configuration responsible for customizing the label for response operation. This takes effect when rendering AsyncAPI v3 documents.
101102 This field is set to ` REPLY ` by default.
102103
104+ - ** extensions?: Record<string, React.ComponentType<ExtensionComponentProps >>**
105+
106+ This field contains configuration responsible for adding custom extension components.
107+ This field will contain default components.
108+
103109## Examples
104110
105111See exemplary component configuration in TypeScript and JavaScript.
@@ -110,6 +116,7 @@ See exemplary component configuration in TypeScript and JavaScript.
110116import * as React from " react" ;
111117import { render } from " react-dom" ;
112118import AsyncAPIComponent , { ConfigInterface } from " @asyncapi/react-component" ;
119+ import CustomExtension from " ./CustomExtension" ;
113120
114121import { schema } from " ./mock" ;
115122
@@ -126,13 +133,28 @@ const config: ConfigInterface = {
126133 expand: {
127134 messageExamples: false ,
128135 },
136+ extensions: {
137+ ' x-custom-extension' : CustomExtension
138+ }
129139};
130140
131141const App = () => <AsyncAPIComponent schema = { schema } config = { config } />;
132142
133143render (<App />, document .getElementById (" root" ));
134144```
135145
146+ ``` tsx
147+ // CustomExtension.tsx
148+ import { ExtensionComponentProps } from ' @asyncapi/react-component/lib/types/components/Extensions' ;
149+
150+ export default function CustomExtension(props : ExtensionComponentProps <string >) {
151+ return <div >
152+ <h1 >{ props .propertyName } </h1 >
153+ <p >{ props .propertyValue } </p >
154+ </div >
155+ }
156+ ```
157+
136158### JavaScript
137159
138160``` jsx
@@ -162,6 +184,16 @@ const App = () => <AsyncAPIComponent schema={schema} config={config} />;
162184render (< App / > , document .getElementById (" root" ));
163185```
164186
187+ ``` jsx
188+ // CustomExtension.jsx
189+ export default function CustomExtension (props ) {
190+ return < div>
191+ < h1> {props .propertyName }< / h1>
192+ < p> {props .propertyValue }< / p>
193+ < / div>
194+ }
195+ ```
196+
165197In the above examples, after concatenation with the default configuration, the resulting configuration looks as follows:
166198
167199``` js
@@ -188,6 +220,10 @@ In the above examples, after concatenation with the default configuration, the r
188220 sendLabel: ' SEND' ,
189221 receiveLabel: ' RECEIVE' ,
190222 requestLabel: ' REQUEST' ,
191- replyLabel: ' REPLY'
223+ replyLabel: ' REPLY' ,
224+ extensions: {
225+ // default extensions...
226+ ' x-custom-extension' : CustomExtension
227+ }
192228}
193229```
0 commit comments