schultek/jaspr

Problem with provisioning of my InheritedWidget

Closed this issue · 5 comments

Hello, I created my custom Inherited Widget for change of my theme in my project:

Screenshot 2024-08-22 at 17 52 00

And added it here:
Screenshot 2024-08-22 at 17 52 44

And here:
Screenshot 2024-08-22 at 17 53 11

But when I want to obtain it in my component:
Screenshot 2024-08-22 at 17 53 43

I gain error output:
Screenshot 2024-08-22 at 17 54 29

Here is my error log:
Screenshot 2024-08-22 at 17 56 31

Interesting is that after reload it looks good but after one second I see error message:
https://github.com/user-attachments/assets/5c6180c4-ba28-4233-b3b4-6b4209d9ae56

Yes I guess Theme is only server-side rendered but you try to access it also from a client component.

Check the hydration docs, specifically the section about the server vs client gap.

Tbh for this use-case (inherited component somewhere up the tree, needs to be accessed further down on the client) I don't have a good solution right now (... but something I'm working on really cool)

Your choices right now are pretty much limited to
a) put the InheritedWidget in a client component or
b) don't access it from the client

Ok, so if I understand correctly, I have to provide my inherited widget inside every page or component annotated by @client annotation.
Now when I added my inherited widget into my Home page so it works.

Screenshot 2024-08-22 at 19 13 12

Seems like this is done.