-
Notifications
You must be signed in to change notification settings - Fork 976
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
Wrapper component instead of an enhancer function (HOC) #16
Comments
I'm finding the component way easier as well. I'm using this: import React, { PropTypes } from 'react';
import { SortableContainer, SortableElement, SortableHandle } from 'react-sortable-hoc';
export const SortHandle = SortableHandle(({ children }) => children);
export const SortElement = SortableElement(({ children }) => children);
export const SortContainer = SortableContainer(({ children, wrapper = 'div' }) =>
React.createElement(wrapper, { children })
);
SortHandle.propTypes = { children: PropTypes.node };
SortElement.propTypes = { children: PropTypes.node };
SortElement.propTypes = {
children: PropTypes.node,
wrapper: PropTypes.string.isRequired
}; |
Hey @dbachrach, thanks for sharing this. I think it's a neat approach for people who'd rather go down the component route. Having said that, the idea is to keep I'm going to close this issue because I see this as a non-issue and don't want newcomers to be under the impression that there are plans to move in this direction. Feel free to re-open with a PR if you feel strongly about this, and we can discuss there. |
@clauderic Sounds fair. I mostly wanted to post this for anyone in the future looking to go down the component route. Thanks. |
First-off thank you for this great library.
I recently realized that it better to have a wrapper component (like what React-Draggable does) then to have an HOC.
And so I was wandering what is the reasoning behind this choice, and if it's possible to have a non HOC version of the wrappers.
I would be happy to do a PR to add this feature.
Advantages to using a wrapper component
withRef
option.displayName
generation (=> cleaner in the dev-tools panel)Usage example
or
The text was updated successfully, but these errors were encountered: