ant-design / ant-design/cssinjs

Cache singleton causes problems with multi-StyleProvider apps (or WebComponents)

Open
#83 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
287
Forks
80
PR merge metrics
No merged PRs in 30d

Description

We use Lit WebComponents to structure our Micro/UI-Composition "widgets".
In ant 4 we injected our styles and overrides in each WC´s head.
The new StyleProvider however provides us with a convenient component={Element} props.

But when instantiating the WebComponent multiple times we see that Ant reuses the Context config and injects the style only in the first component (e.g. the config is a singleton).

Expected:
The CSS to be injected in the specified Element as specified for each element (in our case each WC's shadowroot).

Actuall:
Injected in the first provided Element and ignoring the additional configs.

Repro:
https://stackblitz.com/edit/react-ts-isblup?file=index.tsx,index.html

Similar to #28

@felixschorer Did you not come across this problem?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the linked StackBlitz reproduction and compare the StyleProvider behavior when multiple WebComponents provide different elements. Read the related issue #28 and trace how the singleton context configuration is reused. Done means styles are injected into each specified element rather than only the first one.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.