Cant get basic version working in React?
See original GitHub issueI’m not sure if Im missing something basic but the following does nothing. I would expect something to get logged to the console when I tried to drag?
import React from "react";
import Moveable from "react-moveable";
class SomeComponent extends React.Component {
render() {
return (
<React.Fragment>
<div className="draggable">
<div>Drag me</div>
</div>
<Moveable
target={document.querySelector(".draggable")}
draggable={true}
throttleDrag={0}
onDragStart={res => {
console.log(res);
}}
onDrag={res => {
console.log(res);
}}
/>
</React.Fragment>
);
}
}
export default SomeComponent;
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Create React App not working - Stack Overflow
1. update the npm version (npm install npm@latest -g) · 2. clear the cache (npm cache clean --force) · 3. create the react...
Read more >Versioning Policy - React
Alpha and canary versions of React. We provide alpha versions of React as a way to test new features early, but we need...
Read more >Fixing the 'cannot GET /URL' error on refresh with React ...
The first, set up both client and server side routing. The second, redirect all server requests to /index.html which will download all the...
Read more >Troubleshooting | React Navigation
Before troubleshooting an issue, make sure that you have upgraded to the latest available versions of the packages. You can install the latest...
Read more >How To Set Up a React Project with Create React App
If you stopped the server, be sure to restart it with npm start . Now, take some time to see the parts of...
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 FreeTop 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
Top GitHub Comments
Quickly reopening just so I can share some code of this working incase it helps someone else finding this issue. Here is the codepen link: https://codesandbox.io/s/recursing-archimedes-jzw6p
@jameschetwood thank you! None of the examples on the repo are actually helpful.
Yours works with 1 modification:
const Movable = ({ moveRef, setStyle }) => {
should be
const MovableComponent = ({ moveRef, setStyle }) => {
Here is a full working example that can be pasted into App.js of a new react-create-app app: