Component crashes
Hi and thanks for react-select!
I want to use react-select in apache/couchdb-fauxton
The component renders if I disable it:
<Select
ref="stateSelect"
disabled={true}
options={options} />
However when I enable it, it crashes with:
Warning: React.createElement: type should not be null, undefined, boolean, or number. It should be a string (for DOM elements) or a ReactClass (for composite components). Check the render method of `Select`.
Uncaught Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. Check the render method of `Select`.
I already tried a lot of things to fix it, but I am quite puzzled now. Here is the full code which crashes:
var STATES = [
{ value: 'australian-capital-territory', label: 'Australian Capital Territory', className: 'State-ACT' },
{ value: 'new-south-wales', label: 'New South Wales', className: 'State-NSW' },
{ value: 'victoria', label: 'Victoria', className: 'State-Vic' },
{ value: 'queensland', label: 'Queensland', className: 'State-Qld' },
{ value: 'western-australia', label: 'Western Australia', className: 'State-WA' },
{ value: 'south-australia', label: 'South Australia', className: 'State-SA' },
{ value: 'tasmania', label: 'Tasmania', className: 'State-Tas' },
{ value: 'northern-territory', label: 'Northern Territory', className: 'State-NT' },
];
var JumpToDatabaseWidget = React.createClass({
render: function () {
var options = STATES;
return (
<div>
<Select
ref="stateSelect"
disabled={false}
options={options} />
</div>
);
}
});
Here is a screenshot with the stacktraces:

Do you have an idea what I am doing wrong?
react-select is now controlled, so pass value and an onChange handler.
Weird error though... if that's it, we should improve that :)
hm didn't help:
<Select
onChange={function () {}}
value="blerg"
ref="stateSelect"
disabled={false}
options={options} />
branch is at https://github.com/robertkowalski/couchdb-fauxton/tree/react-select
I smell a require.js / react-select interop issue... I'll take clone it and take a look - probably not till early next week though :(
my awesome coworker @garrensmith found out that the 'react-input-autosize is not loaded properly with AMD - we'll keep you updated!
I put
<script src="https://localhost:8000/js/react-input-autosize.js"></script>
and it helps
I have the same issue
<Select.Async name="form-field-name" value="one" loadOptions={getOptions} />
Gives me:
Uncaught Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined.
we switched to webpack and it solved our issue
Thanks for the update @robertkowalski - I'll see what I can do to test this for the next build and update the instructions for AMD usage... we could probably detect that react-input-autosize is not loading correctly and warn on that, which would at least make this problem an easier one to debug.
I'm also getting the same error as @mharrisweb
It seems that instead of using <Select.Async loadOptions={} /> the approach that works is <Select asyncOptions={} /> but that doesn't seem to be in the documented options here although there are references to it.
+1 @skbailey I had exactly the same problem, using asyncOptions fixed it.
I use version ^0.9.1 - maybe something changed?
Not sure if this is going to help anyone, but I was using import { Select } from 'react-select' instead of var Select = require('react-select'). Once I changed it to var Select = require('react-select'), it worked.
Seems to be related to #270
@anton6 Alternatively use:import Select from 'react-select'. (it's the default export, so no braces required)
Thanks @skbailey!
Using asyncOptions fixed this strange behaviour.
I'm getting Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. in version 1.0.0-rc.1
import Select from 'react-select';
<Select.Async {...this.props}
ref='selectField'
value={this.getSavedValue()}
loadOptions={this.getItems.bind(this)}/>
I don't want to use asynOptions as this would mean down grading. Has there been a fix put in place for this?
Hey guys,
I am currently going threw an upgrade of a few modules.
I am getting the same error as above
Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object. You likely forgot to export your component from the file it's defined in. Check the render method of `DestinationInputField`.
I import it like this ->
import Select from 'react-select';
My component looks like this ->
<div id="destination-input">
<FormFieldWrapper label="Destination"
help={errorMessage}>
<Select
id="destination-input"
name="destination"
onChange={this.destinationSelected.bind(this)}
options={destinationOptions}
multi={true}
value={selectedDestinationId}
placeholder="All Destinations"
/>
</FormFieldWrapper>
</div>
I am on version 1.0.0-rc.3 with the latest version of react 15.4.2 and react-dom 15.4.2
Any help would be great.
Same issue as those above: type is invalid -- expected a string(for built-in components)...
All that's required to throw the error is
import Select from react-select
<Select />
Having the same issue. webpack/es2015