You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a custom element has an observed attribute, a context provider will not take a value.
constThemeContext=createContext('light');functionTheme({ children, theme ='dark'}){// We can read the value being passed in:console.log(theme);// 'dark'// But the provider below will not set its value to 'dark'.//// Any children using the context will get 'light'.//// Even if we passed in a value directly:// <ThemeContext.Provider value={'blue'}>// the children will still get 'light'.return(<ThemeContext.Providervalue={theme}><div>{children}</div></ThemeContext.Provider>);}// Removing the "theme" attribute below resolves the issue. The context will then take a value.registerElement(Theme,'x-theme',['theme'],{shadow: true});
When a custom element has an observed attribute, a context provider will not take a value.
Full working example:
https://stackblitz.com/edit/vitejs-vite-fwbe4e?file=src/app.jsx (may need to run
yarn dev
in the console)The text was updated successfully, but these errors were encountered: