Alex
Alex

Reputation: 433

React createElement type should not be null/ Uncaught Invariant Violation

I'm trying to render a multi-select component within a nav bar but am coming back with these errors:

warning.js:36Warning: 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 EventsFilters.

invariant.js:38 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 EventsFilters.

Pointers in the right direction would be greatly appreciated.

Filter Code:

import React from 'react';

//Event Types Filter
class EventsFilters extends React.Component {
  //Define react properties
  static propTypes: {
    setLocalStorage: 'jjj',
    selectedFilters: 'sds',
  }

render() {

var SelectList = React.SelectList;
var items = [
  {id: 0, name: 'Workflow Event'},
  {id: 1, name: 'Dev Event'},
];

//Event Workflow Select List
var EventsWorkflowFilters = (
<div>
  <SelectList
          textField='name'
          valueField='id'
          className='selectlist-unstyled list-inline filter-list'
          defaultValue={[0]}
          data={items}
          multiple="true" />
</div>
)



return(EventsWorkflowFilters)

}}

export default EventsFilters;

Upvotes: 1

Views: 152

Answers (1)

Richard Casetta
Richard Casetta

Reputation: 446

React does not provide a SelectList component so your SelectList variable is undefined, you need to do it yourself or check on npm if someone already has. For example you can use https://www.npmjs.com/package/react-select and check the documentation to see how to use it.

Hope this help

Upvotes: 1

Related Questions