user9728810
user9728810

Reputation:

ES6 wrap component within component

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

Answers (2)

Rushikesh Bharad
Rushikesh Bharad

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

Stout01
Stout01

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

Related Questions