-
-
Notifications
You must be signed in to change notification settings - Fork 739
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
Introduce context provider in view component #6395
Conversation
✅ Deploy Preview for plone-components canceled.
|
@ksuess Thanks for the PR. However, I have some doubts that I'd like to discuss this further in the Volto Team Meeting. Let me mention some of my concerns here:
|
I'm fine with using a different technique. And I am fine with talking about this during the next meeting. Just a note why I don't use component state or global Redux state: The view renders an array of blocks. |
How do the blocks update the context? How do the blocks check for a match?
Every time you do a
Are you sure that they do not re-render? |
I understand that the official documentation seams to say that all components under the provider that call 'useContext' gets re-rendered on context changes. https://react.dev/reference/react/useContext#caveats But this is not the case. They subscribe to the context, yes, but are touched only if they really change. My solution with the context provider in 'View.jsx' plus the PR mentioned in the issue (rohberg/volto-slate-glossary#8) is fullfilling the request 'tooltips only on first occurrence on a page (over all blocks). It does it in a minimal invasive manner. I am sorry that there seams to be no solution without a change in Volto and that I take up your time. |
@ksuess as @sneridagh said let's discuss this at the Volto team meeting. Personally, I want to have the chance to test your add-on with these changes. Besides this, I am curious to see what would happen if for instance Jotai is used or even Redux. This means that up to this point, we were able to develop without the need for Context Providers and this might still be the case going forward but it's good to have a use case where a potential React feature is needed and for us to see if we truly need it or not. |
@ksuess I just installed collective.glossary and your branch from volto-slate-glossary As soon as I try to edit the frontpage I get this error and what's strange is that the error counter continues to increase as I remain on the error page. In the screenshot you see 1 or 104 but every second it was increasing so after a few seconds it said 1 of 120. Has this ever happened to you and if so what did you do to solve it? |
New concept for volto-slate-glossary: Instead of generating the tooltip enhanced markup in each Slate leaf, The advantage of this is, that we do not write, but only read, in slate text leaves. This means we don't have to worry about re-rendering the leaves when the status changes. BTW Global state management with Jotai is a pleasure! |
Closing in favor of a solution without the need of a change request in Volto core. |
I know! :) Glad you liked it! |
Fix #6394
📚 Documentation preview 📚: https://volto--6395.org.readthedocs.build/