Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modern usage of sortable is not working for me #37

Closed
dineshvgp opened this issue Apr 18, 2016 · 2 comments
Closed

Modern usage of sortable is not working for me #37

dineshvgp opened this issue Apr 18, 2016 · 2 comments

Comments

@dineshvgp
Copy link

I have changed the DemoItem.js as follows:

import React from 'react';
import { sortable } from '../../src/index.js';

@sortable
class DemoItem extends React.Component {
  render() {
    return (
      <div className={this.props.className}>
        {this.props.children}
      </div>
    );
  }
};

export default DemoItem;

The above one doesn't work for me. Please correct me if I'm doing something wrong.

@jasonslyvia
Copy link
Owner

As the docs states, you have to destructure this.props to your item to assign some event handlers passed by Sortable.

import React from 'react';
import { sortable } from '../../src/index.js';

@sortable
class DemoItem extends React.Component {
  render() {
    const { className, ...rest } = this.props;
    return (
      <div className={this.props.className} {...rest}>   // <-- here
        {this.props.children}
      </div>
    );
  }
};

export default DemoItem;

@dineshvgp
Copy link
Author

Oh I haven't read the docs well. Thanks, this works great!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants