File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -245,6 +245,19 @@ onStop: DraggableEventHandler,
245245// This can be used for arbitrarily nested components, so long as the ref ends up
246246// pointing to the actual child DOM node and not a custom component.
247247//
248+ // For rich components, you need to both forward the ref *and props* to the underlying DOM
249+ // element. Props must be forwarded so that DOM event handlers can be attached.
250+ // For example:
251+ //
252+ // const Component1 = React.forwardRef(function (props, ref) {
253+ // return <div {...props} ref={ref}>Nested component</div>;
254+ // });
255+ //
256+ // const nodeRef = React.useRef(null);
257+ // <DraggableCore onDrag={onDrag} nodeRef={nodeRef}>
258+ // <Component1 ref={nodeRef} />
259+ // </DraggableCore>
260+ //
248261// Thanks to react-transition-group for the inspiration.
249262//
250263// `nodeRef` is also available on <DraggableCore>.
You can’t perform that action at this time.
0 commit comments