@@ -152,16 +152,29 @@ export default class Resizable extends React.Component<Props, void> {
152152 } ;
153153 }
154154
155- // Render a resize handle given an axis & DOM ref.
155+ // Render a resize handle given an axis & DOM ref. Ref *must* be attached for
156+ // the underlying draggable library to work properly.
156157 renderResizeHandle ( handleAxis : ResizeHandleAxis , ref : ReactRef < HTMLElement > ) : ReactNode {
157158 const { handle} = this . props ;
158- if ( handle ) {
159- if ( typeof handle === 'function' ) {
160- return handle ( handleAxis , ref ) ;
161- }
162- return React . cloneElement ( handle , { ref, handleAxis} ) ;
159+ // No handle provided, make the default
160+ if ( ! handle ) {
161+ return < span className = { `react-resizable-handle react-resizable-handle-${ handleAxis } ` } ref = { ref } /> ;
162+ }
163+ // Handle is a function, such as:
164+ // `handle={(handleAxis) => <span className={...} />}`
165+ if ( typeof handle === 'function' ) {
166+ return handle ( handleAxis , ref ) ;
163167 }
164- return < span className = { `react-resizable-handle react-resizable-handle-${ handleAxis } ` } ref = { ref} / > ;
168+ // Handle is a React component (composite or DOM).
169+ const isDOMElement = handle . type === 'string' ;
170+ const props = {
171+ ref,
172+ // Add `handleAxis` prop iff this is not a DOM element,
173+ // otherwise we'll get an unknown property warning
174+ ...( isDOMElement ? { } : { handleAxis} )
175+ } ;
176+ return React . cloneElement ( handle , props ) ;
177+
165178 }
166179
167180 render ( ) : ReactNode {
@@ -173,8 +186,8 @@ export default class Resizable extends React.Component<Props, void> {
173186
174187 // What we're doing here is getting the child of this element, and cloning it with this element's props.
175188 // We are then defining its children as:
176- // Its original children (resizable's child's children), and
177- // One or more draggable handles.
189+ // 1. Its original children (resizable's child's children), and
190+ // 2. One or more draggable handles.
178191 return cloneElement ( children , {
179192 ...p ,
180193 className : `${ className ? `${ className } ` : '' } react-resizable` ,
0 commit comments