title: How to fix Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object
body: <p>I am trying to run ReactRails app and trying to run a very simple react-select component. However, in the same file if I print just a simple <code>h2</code> element it works but <code>&lt;Select/&gt;</code> doesn't work. It gives:</p>
  
  <pre><code>Uncaught Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.
  </code></pre>
  
  <p>I am trying to use <code>react-select</code> component. I've installed it via <code>yarn add</code> command.</p>
  
  <p><strong>User.jsx:</strong></p>
  
  <pre><code>var React = require("react")
  var Select = require("react-select")
  var PropTypes = require("prop-types")
  
  // also tried these -&gt;
  // import React from 'react';
  // import createClass from 'create-react-class';
  // import PropTypes from 'prop-types';
  // import Select from 'react-select';
  
  
  const options = [
    { value: 'chocolate', label: 'Chocolate' },
    { value: 'strawberry', label: 'Strawberry' },
    { value: 'vanilla', label: 'Vanilla' }
  ];
  
  class User extends React.Component {
    state = {
      selectedOption: null,
    }
    handleChange = (selectedOption) =&gt; {
      this.setState({ selectedOption });
      console.log(`Option selected:`, selectedOption);
    }
    render() {
      const { selectedOption } = this.state;
  
      /*
      return (
               &lt;h2&gt;THIS WORKS!&lt;/h2&gt;
      )
      */
  
  
  
      return (
               &lt;Select
                   value={selectedOption}
                   onChange={this.handleChange}
                   options={options}
               /&gt;
      )
  
      // Doesn't work:
      // Uncaught Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.
  
    }
  }
  module.exports = User
  </code></pre>
  
  <p>I am very new to React world. What Am I missing here? What am I doing wrong?</p>
  
  <p>Note: This did not solved my problem: <a href="https://stackoverflow.com/questions/34130539/uncaught-error-invariant-violation-element-type-is-invalid-expected-a-string">Uncaught Error: Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function but got: object</a></p>