erizocosmico/react-categorized-tag-input

Warning: React.createElement: type should not be null && Error: Element type is invalid:

dwasyluk opened this issue · 3 comments

First off thanks for this very well-written component for tag input. I'm struggling to get this working with my project, I've verified the version on npm works with a greenfields project (tested using https://github.com/unicorn-standard/starter-kit) but something in my project is leading to these two errors in the browser console and the app failing to run anytime I include a in my render functions:

Error1: 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 InputTest.
Error2: Error: 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 InputTest.

I'm using webpack, ES6, TS2, React 0.15/React-Router/React-DOM (I tried with 0.14 as well but same error). Any ideas on what I'm doing wrong? Google results indicate a myriad of possible causes none of which seem to have resolved the issue for me, thanks in advance for any help!

Hi @mvader thanks for the quick response, I should have clarified InputTest was just a simple wrapper component I had TagInput within. I figured out what was wrong with the help of some of my colleagues, will leave it here for future Googlers 👍 -

If you are trying to use this component with Typescript, the import syntax of:
import TagInput from '...' will fail at runtime and will lead to the errors mentioned in my OP. To resolve the issue you must change the import syntax as such: import * as TagInput from '...' and the issue will be resolved.

We were hypothesizing that the need for this might be because the code built for distribution via NPM is non-ES6, possibly with some flavor of UMD for modules but that was just a hypothesis. Hope this saves someone a headache down the line 😄

Oh, it might be because of that. I will try to look into it when I have some time. Maybe it's just a typescript thing but it's worth the check.

Thanks!