Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebComponentWrapper not passing props to the web element #412

Open
pdashford opened this issue Dec 18, 2023 · 2 comments
Open

WebComponentWrapper not passing props to the web element #412

pdashford opened this issue Dec 18, 2023 · 2 comments

Comments

@pdashford
Copy link

Whne using the WebComponentWrapper and setting the props property this does not appear to set the value into the web element component.

[props]={ 'user': 'test'}

However when checking for the property in a React component the value is null.

Has anyone else experienced the same issue.

class ReactMfe extends HTMLElement {
connectedCallback() {
const mountPoint = document.createElement('div');
this.attachShadow({ mode: 'open' }).appendChild(mountPoint);
const user = this.getAttribute('user');
console.log('🚀 ~ file: app.tsx: ~ user:', user)
const root = ReactDOM.createRoot(mountPoint as HTMLElement);
root.render();
}
}

customElements.define('caracal-admin', ReactMfe);

@AndreasLoukakis
Copy link

AndreasLoukakis commented Dec 18, 2023

Maybe you should try accessing this.user from within the ReactMfe class. You are passing properties, not attributes.

@pdashford
Copy link
Author

Super thank you yes that worked. There doesnt seem to be any good examples of using the props with the wrapper. Thanks again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants