Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug:控制台报错,Element type is invalid #888

Closed
lucian55 opened this issue Nov 2, 2018 · 2 comments
Closed

Bug:控制台报错,Element type is invalid #888

lucian55 opened this issue Nov 2, 2018 · 2 comments

Comments

@lucian55
Copy link

lucian55 commented Nov 2, 2018

在使用的时候控制台报错,如下:

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 `DragHandle`.

Uncaught 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 `DragHandle`.


查看了好多 issue ,发现有可能是 react 版本问题。但是我的 react 版本是 16.6.0 了,依旧报错。
请帮助我,谢谢

代码如下


<DragDropContext onDragEnd={this.onDragEnd} onDragStart={this.onDragStart} onDragUpdate={onDragUpdate}>
        <Droppable droppableId="droppable" direction={type} >
          {(provided, snapshot) => (
            <div
              ref={provided.innerRef}
              className={classnames({
                ...getClass(this.props,snapshot.isDraggingOver).drop
              })}
            >
              {this.state.items.map((item, index) => (
                <Draggable key={index} draggableId={index} index={index}>
                  {(provided, snapshot) => (
                    <div
                      ref={provided.innerRef}
                      {...provided.draggableProps}
                      {...provided.dragHandleProps}
                      className={classnames({
                        ...getClass(this.props,snapshot.isDragging).drag
                      })}
                      style={{...provided.draggableProps.style}}
                    >
                      {showKey?item[showKey]:item}
                    </div>
                  )}
                </Draggable>
              ))}
             {provided.placeholder}
            </div>
          )}
        </Droppable>
      </DragDropContext>


@lucian55 lucian55 changed the title bug:Element type is invalid Bug:控制台报错,Element type is invalid Nov 2, 2018
@TrySound
Copy link
Contributor

TrySound commented Nov 2, 2018

@liushaozhen Seems like you use invalid version of react. Take a look at package.json. The version should be 16.3.1 or greater.

@alexreardon
Copy link
Collaborator

Thanks @TrySound.

This is such a common issue I am adding a warning to version 10 #838

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants