Skip to content

Drag and drop a Canvas #197

Answered by ankri
real-ashwin asked this question in Q&A
Feb 20, 2021 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

So when this is your Container

const Container: UserComponent = ({ children }) => {
  const {
    connectors: { drag, connect }
  } = useNode();

  return <div ref={(ref) => connect(drag(ref))}>{children}</div>;
};

you can create it as a canvas

      <button
        ref={(ref) => connectors.create(ref, <Element canvas is={Container} />)}
      >
        Container
      </button>

You can have a look at the Basic Example / Container and Basic Example / Toolbox


So if you want your Component to be a Canvas, you create it as a Canvas. (note: <Canvas /> has been deprecated - use <Element canvas /> instead)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@real-ashwin
Comment options

Answer selected by real-ashwin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants