craft.js
craft.js copied to clipboard
actions.add node bug
I try to add a UserComponent Node to editor by actions.add
then when i select this component to show the edit panel by actions.selectNode, there console an error :
i try to analysis this error and here is what i find out:
the context is null when the code run:
who can help me...
Your user component seems to not be a child of <Editor />
. Please make sure that (what I assume to be) your toolbar that contains the UserComponent is also a child of Editor
For example:
+<Editor>
<Toolbar>
+ <ElementThatCallsActionsAdd />
</Toolbar>
<Frame>
<YourFrameContent />
</Frame>
</Editor>
after a few hours, I finally finger out why
when i call actions.add to add a component manully, my related component is not wrapped by NodeProvider, therefor, when i call usenode hooks in the related component, i have an error.
so ,i need to wrap my related component by NodeProvider manully like this:
But in the source code of utils/createNode, the related component is wrapped by NodeProvider
so this is may be a bug of actions.add
Can you please paste the full code for this image and the code where you use the this component. And your code where you use
<Editor />
.
Please look at my suggestion again an confirm that you creating related.settings
only in descendants of <Editor />