What is the correct syntax for calling SortableXxxxxx in a Class rather than a Constant? I cant' seem to make it work in a class?
const MyElement = SortableElement(observer((props) => {
return (
<li> (...do stuff here...) </li>
)
}));
Should look like
@observer
class MyElement extends React.Component {
constructor (props) {
super(props);
autobind(this);
}
( ... methods here ... )
render () {
return (
SortableElement( {<li> (...do stuff here...)</li>})
);
}
}
Nothing I have tried seems to work?
What am I clueless about?
Thanks.
Sigh. I'm stuck. Can't progress unless I get past this problem.
You need to define your enhanced SortableElement component outside of the render method. Try something like this instead:
class Item extends React.Component {
render() {
return (
<li> (...do stuff here...)</li>
);
}
}
const SortableItem = SortableElement(Item);
@observer
class MyElement extends React.Component {
constructor (props) {
super(props);
autobind(this);
}
( ... methods here ... )
render () {
return (
<SortableItem index={0} (and pass all other relevant props here) />
);
}
}
OMG. I get it. Thank you. Thank you. Thank you. :)
Most helpful comment
You need to define your enhanced SortableElement component outside of the render method. Try something like this instead: