Skip to content

Commit 6a03131

Browse files
docs: mention scoping in FAQ and Migration Guide (#7439)
1 parent bfaee07 commit 6a03131

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

docs/MigrationGuide.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ For a complete list of breaking changes in UI5 Web Components, please refer to t
2424

2525
_**Note:** Our `codemod` covers changes from ui5-webcomponents as well._
2626

27+
_**Note:** Setting the scoping suffix should be done before importing any components, as they use the suffix at the top-level of the module - meaning when a component is imported, the suffix has to be known.
28+
For this to work, calling the method should be done in a separate module (e.g. scoping-config.js) and this module should be imported before any components are imported._
29+
2730
## Codemod
2831

2932
To make the migration to UI5 Web Components (for React) v2 easier,

docs/knowledge-base/FAQ.mdx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,23 @@ Each component developed by the UI5 Web Components team ([`ui5-webcomponents`](h
8686

8787
If a component does not have this note, it is a React-only component provided exclusively by `ui5-webcomponents-react`.
8888

89+
## Scoping
90+
91+
Starting from UI5 Web Components (for React) 2.0.0, the order if imports with regards to scoping and components matters.
92+
Setting the scoping suffix must be done before importing any components, as they use the suffix at the top-level of the module - meaning when a component is imported, the suffix has to be known.
93+
For this to work, calling the method should be done in a separate module (e.g. scoping-config.js) and this module should be imported before any components are imported.
94+
You can find more information about this in the [UI5 Web Components documentation](https://sap.github.io/ui5-webcomponents/docs/advanced/scoping/).
95+
96+
```ts
97+
// scoping-config.js
98+
import { setCustomElementsScopingSuffix } from '@ui5/webcomponents-base/dist/CustomElementsScope.js';
99+
setCustomElementsScopingSuffix('demo');
100+
101+
// app main file, e.g index.js, main.tsx, etc.
102+
import './scoping-config.js';
103+
// now, all other component imports - the scoping config import must be the first import of the app
104+
import { Button } from '@ui5/webcomponents-react';
105+
// ...
106+
```
107+
89108
<Footer />

0 commit comments

Comments
 (0)