Improve connectors
See original GitHub issueCurrently the usage is this
const { connectors: { connect, drag } } = useNode();
// and then
return <div ref={connect}>
// which is basically this
return <div ref={ref => connect(ref)}>
// or with drag
return <div ref={ref => connect(drag(ref))}>
Could we instead use this pattern, so that in future, when there are more methods, we can combine them simpler?
return <div ref={ref => connect(ref, drag, drop)}>
// instead of
return <div ref={ref => connect(drag(drop(ref)))}/>
or even let connect() return curried itself if it doesn’t detect a ref for these cases
return <div ref={connect}> // this is OK already
return <div ref={ref => connect(ref)}> // this is OK already
return <div ref={connect()}>
return <div ref={ref => connect()(ref)}>
return <div ref={connect(drag)}>
return <div ref={connect(drag, drop)}>
return <div ref={ref => connect(drag, drop)(ref)}>
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Connector Lubricants Improve Reliability and Longevity
Manufacturers can reduce or eliminate most connector issues simply by applying the right lubricant to contacts.
Read more >Go with the Flow! 37 English Connectors to Improve Your ...
Learning how to use English connectors is important for improving your speaking and writing skills. Read this blog post to learn 37 common ......
Read more >Improving conductivity of electrical connectors
Improving conductivity of electrical connectors · Best practice is to make sure they are clean and tight. · The plugs and socket connection...
Read more >Mavim-iMprove (Preview) - Connectors - Microsoft Learn
With the Mavim connector you are able to build a digital twin of your organization by visualizing the relationships among people, process and...
Read more >HOW TO USE CONNECTORS IN ENGLISH TO IMPROVE ...
Today is all about connecting words in English! DON'T REPEAT and, but and because - IT'S BORING! Diversify your language with these ten ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I will reply your question regarding why we don’t have a
drop
connector from the earlier issue here as it seems more fitting.There is no
drop
connector because of the core concepts in Craft.js (Nodes and Canvas Nodes). The<Canvas />
component, creates aCanvas
Node (droppable region) and enables each of its immediate child Node to be draggable. The<Canvas />
component then renders each Node by its elementtype
.If we expose a
drop
connector, then it must somehow also control what the connected DOM would render, which is not ideal since we want React to handle rendering.p.s. Consider joining our Discord server 👋🏽
The thing is that all the suggested patterns would be supported.
A possible implementation is that all connectors would be abstracted away behind a common “invoker”, which would be allowed to accept other connectors or ref and would return another invoker until it receives a ref. Playground Link