-
Notifications
You must be signed in to change notification settings - Fork 1
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
error when component uses context #1
Comments
Hi @WickyNilliams , thank you for notifying this issue. At the moment, I am unable to replicate it. My reference code indicates that the context dispatches the event from a useState. This could fail if the host is equal to undefined, but even with SSG, it does not generate errors locally. import { c, createContext, useContext } from "atomico";
export const MyContext = createContext({ value: 0 });
export const MyComponent = c(() => {
const { value } = useContext(MyContext);
return (
<host shadowDom>
<h1 style="color: white">contexto!</h1>
</host>
);
});
customElements.define("my-context", MyContext);
customElements.define("my-component", MyComponent); Instance example 1:import "./atomico";
---
<my-context>
<my-component></my-component>
</my-context> Instance example 2:import { MyContext, MyComponent } from "./atomico";
---
<MyContext>
<MyComponent/>
</MyContext> Do you think it's possible for you to replicate that bug in this template? https://stackblitz.com/edit/atomico-astro?file=package.json |
From the stack trace I would guess that the context event is being fired on the server, since I'll try to create a reduced test case and report back. |
OK here's a repro https://stackblitz.com/edit/atomico-astro-jkqadd Looking at the code here, it will try to |
Thank you for the code. I have fixed this in atomico@1.77.2. |
Great thanks! This seems to have fixed this specific bug. But I've hit some other weirdness. I'll see if I can whip up a reduced test case Monday. Thanks again |
i have some components using context, and when i try SSR in astro i get the following error logged in the CLI terminal:
which surfaces in the browser as an astro error:
where
offset
is a prop in my component that consumes the context.my astro config looks like this:
and my astro page looks like:
The text was updated successfully, but these errors were encountered: