2

I have MultiDayPicker component which looks like this:

export default class MultiDayPicker extends Component {
  state = {
    selectedDays: []
  };

  handleDayClick = (day, {selected}) => {
    const { selectedDays } = this.state;
    if (selected) {
      const selectedIndex = selectedDays.findIndex(selectedDay =>
        DateUtils.isSameDay(selectedDay, day)
      );
      selectedDays.splice(selectedIndex, 1);
    } else {
      selectedDays.push(day);
    }
    this.setState({ selectedDays });
  };

  render() {
    return (
        <DayPicker
          selectedDays={this.state.selectedDays}
          onDayClick={this.handleDayClick}
        />
    );
  }
}

Unfortuantely I am getting error like this:

console.error node_modules\fbjs\lib\warning.js:33
      Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object.

Any ideas what could cause this ? Thanks in advance for any suggestions.

JustJSFan
  • 143
  • 1
  • 1
  • 6
  • how are you importing DayPicker? – Manoz Jun 15 '18 at 08:40
  • `import DayPicker, {DateUtils} from 'react-day-picker';` and to answer your future question: `import {DayPicker, DateUtils} from 'react-day-picker';` is not the correct way neither – JustJSFan Jun 15 '18 at 09:06
  • It is perfectly valid then. I use same component as you are doing here. No problems at my side. My be some other library you are importing using destruction `{}` instead of importing it whole – Manoz Jun 15 '18 at 09:28

0 Answers0