Skip to content

Commit 5fdf8cf

Browse files
authored
docs: web components usage in react (#12111)
1 parent 0e095e6 commit 5fdf8cf

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

docs/3-frameworks/01-React.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,31 @@ For boolean properties like ```collapsed``` in ```ui5-panel```, instead of sett
7777
</ui5-panel>
7878
```
7979
80+
### Using UI5 Web Components in TSX
81+
82+
When using UI5 Web Components like `<ui5-input>` in a `.tsx` file, you may encounter the following TypeScript error:
83+
84+
```ts
85+
Property 'ui5-input' does not exist on type 'JSX.IntrinsicElements'. ts(2339)
86+
```
87+
88+
This happens because **TypeScript’s `JSX.IntrinsicElements` only includes standard HTML tags by default** (`<div>`, `<span>`, etc.).
89+
Custom elements, such as those from UI5, are not recognized unless you explicitly declare them.
90+
91+
To make TypeScript aware of your UI5 Web Components, you need to **extend the `JSX.IntrinsicElements` interface** with the custom tags you plan to use.
92+
93+
```ts
94+
declare namespace JSX {
95+
interface IntrinsicElements {
96+
'ui5-input': any; // Replace `any` with a proper type
97+
// Add more UI5 web components here...
98+
}
99+
}
100+
```
101+
102+
Please refer to the [UI5 Web Components React sample](https://github.com/SAP-samples/ui5-webcomponents-sample-react/) for a complete example of using web components in React.
103+
104+
80105
### UI5 Web Components for React
81106
82-
As mentioned above, for a better development experience (and to elegantly work around these 2 React limitations), check out UI5 Web Components for React, [UI5 Web Components for React](https://github.com/SAP/ui5-webcomponents-react) and [this tutorial](https://developers.sap.com/mission.react-spa.html).
107+
As mentioned above, for a better development experience (and to elegantly work around these 3 React limitations), check out UI5 Web Components for React, [UI5 Web Components for React](https://github.com/SAP/ui5-webcomponents-react) and [this tutorial](https://developers.sap.com/mission.react-spa.html).

0 commit comments

Comments
 (0)