react-draggable v4.4.0 Release Notes
Release Date: 2020-05-12 // almost 4 years ago-
- ➕ Add
nodeRef
:- If running in React Strict mode, ReactDOM.findDOMNode() is deprecated.
Unfortunately, in order for
<Draggable>
to work properly, we need raw access to the underlying DOM node. If you want to avoid the warning, pass anodeRef
as in this example:js function MyComponent() { const nodeRef = React.useRef(null); return ( <Draggable nodeRef={nodeRef}> <div ref={nodeRef}>Example Target</div> </Draggable> ); }
This can be used for arbitrarily nested components, so long as the ref ends up pointing to the actual child DOM node and not a custom component. Thanks to react-transition-group for the inspiration.
nodeRefis also available on
`.
- If running in React Strict mode, ReactDOM.findDOMNode() is deprecated.
Unfortunately, in order for
✂ Remove "browser" field in "package.json":
- There is nothing special in the browser build that is actually practical for modern use. The "browser" field, as defined in https://github.com/defunctzombie/package-browser-field-spec#overview, indicates that you should use it if you are directly accessing globals, using browser-specific features, dom manipulation, etc.
React components like react-draggable are built to do minimal raw DOM manipulation, and to always gate this behind conditionals to ensure that server-side rendering still works. We don't make any changes to any of that for the "browser" build, so it's entirely redundant.
This should also fix the "Super expression must either be null or a function" error (#472) that some users have experienced with particular bundler configurations.
The browser build may still be imported at "build/web/react-draggable.min.js". This is to prevent breakage only. The file is no longer minified to prevent possible terser bugs.
- The browser build will likely be removed entirely in 5.0.
🛠 Fix: Make
bounds
optional in TypeScript #473
- ➕ Add