-
Notifications
You must be signed in to change notification settings - Fork 11
Error: The useSlate hook must be used inside the <SlateProvider> component's context #167
Comments
@silviubogan I skipped the cypress tests in order to release it 😄 My fault here. Still I think this error is not catched by the cypress tests. |
It seems that the toolbar button in The first access of the Slate context with the useSlate hook does not find the context. It is first called when focusing a Volto-Slate based block. When making a new page the same bug appears when clicking the Volto-Slate Text block or going with the Down arrow key to the Volto-Slate Text block. This bug appears in a new Volto-based frontend too, when using the latest version of KitKat in the |
The bug appears in the IMS Frontend with a new backend (no content other than default) too, although I've put the volto-slate branch |
Any ideas? |
try to define the components as functions, not anonymous functions. |
@tiberiuichim I've made it like this: const Btn = function () {
useSlate();
return null;
}; then like function Btn() {
useSlate();
return null;
} and they still throw the same error. |
This happens when the following conditions are met:
This cause each volto addon with a volto-slate dependency to keep its own copy of volto-slate, in its local node_modules, so it doesn't get hoisted. Tale-tell: a warning when running yarn:
Action: remove all hard dependencies on volto-slate, replace them with a peerDependency (in each Volto addon that dependns on volto-slate). |
I think my analysis is somewhat incorrect. I think it's safe for an addon to have another addon as a dependency, maybe we need to avoid the resolutions part? |
@tiberiuichim Does Volto work with nested addons? |
@tiberiuichim Is eea/volto-block-image-cards#12 merged by mistake? |
If one addon is installed twice, each time a different version, does it work well in Volto? |
In principal having two different versions of a JS package bundled is not a problem. In our practice we want to avoid this behavior, as it leads to ugly situations like the one in this ticket. How we avoid that situation is not clear to me, though. It seems that simple |
@tiberiuichim Please review this reversion PR: eea/volto-block-image-cards#15. |
This error still persists in latest release. |
@nileshgulia1 this happens when there's multiple versions of volto-slate in a deployment. Check that there's only one version. |
@tiberiuichim Thanks, I started to update few set of addons to use latest volto-slate. |
Latest volto-slate release fails with:
The text was updated successfully, but these errors were encountered: