Reputation:
const Dropdown = createReactClass({
render() {
return 'something'
}
});
module.exports = enhanceWithClickOutside(Dropdown);
How do I use above code in ES6 react?
class Dropdown extends React.Component {
render() {
return 'something'
}
}
//where to put the enhanceWithClickOutside?
I'm trying to use this package https://www.npmjs.com/package/react-click-outside
This is my attempt https://codesandbox.io/s/kx48qx7n63
Upvotes: 0
Views: 153
Reputation: 1010
import React from 'react';
const Dropdown = () => ('something');
export default Dropdown;
OR, if you want to do some computation before return
import React from 'react';
const Dropdown = props => {
// do your computations
return 'something';
};
export default Dropdown;
Upvotes: 0
Reputation: 1126
You will need to export the dropdown class. Something like this: export default enhanceWithClickOutside(Dropdown);
Edited sandbox: https://codesandbox.io/s/lp6jo7yjm
Also, see here for another example: https://github.com/davidhu2000/react-spinners/blob/master/examples/components/color_picker.jsx
Upvotes: 1