命名空间“ React”没有导出的成员“ ConsumerProps”,ProviderProps

时间:2018-08-01 18:47:44

标签: reactjs typescript react-dnd

我正在尝试在Visual Studio中安装此库,我的反应版本是15.0.35。我可以在此版本的React中使用该库吗?如果不是,是否还有其他与此版本兼容的库?

import * as React from 'react';
import { RouteComponentProps, NavLink } from 'react-router-dom';
import { DragEvent } from 'react';
import { ApplicationState } from '../store';
import * as NavMenuStore from '../store/NavMenu';
import { connect } from 'react-redux';
import D4AMenuItem from './D4AMenuItem';
import { State } from 'react-burger-menu';
import CardContainer from './CardContainer';
import {
ConnectDragSource,
DragDropContext,
DragSourceSpec,
DragSource,
DragSourceCollector,
DragSourceConnector,
DragSourceMonitor,
DragElementWrapper,
ConnectDropTarget,
DropTargetConnector,
DropTargetMonitor,
DropTargetSpec
} from 'react-dnd';

 //render method

 public render() {

    let dropped = this.props.SelectedMenuItems.map((menu: any) => {
        return (
            <span 
                key={Math.random()}
                draggable={true}
                onDragStart={(e: DragEvent<any>) => this.onDragStart(e, menu.MenuText)}>
                <NavLink to={menu.RoutePath} activeClassName='active' className='D4AMenuItemNew'>
                    <img className='D4AIconNew' alt='Audit4Action_Icon' src={String(menu.IconPath)}></img>
                    <span className='D4ATextNew'>
                    </span> {menu.MenuText}

                </NavLink>

           </span>    
        );
    })
    return <div >

        <div className='dropping_div' onDragOver={(e: any) => this.onDragOver(e)} onDrop={(e: DragEvent<any>) => this.onDrop(e)}>{dropped}</div>               

        <div><h1>Drag and Drop Containers Over Each Other to Swap Places</h1>
            <CardContainer /> { /*swap={() => this.swap()} drag={(e: DragEvent<any>) => this.drag(e)} cards={this.state.info}*/} </div>

    </div>;
}

}

导出默认连接(     (state:ApplicationState)=> state.navmenu,//选择将哪些状态属性合并到组件的道具中     NavMenuStore.actionCreators //选择将哪些动作创建者合并到组件的道具中 )(如家一样);

1 个答案:

答案 0 :(得分:0)

我能解释该错误的唯一方法是,如果您尝试在React 15中使用react-dnd 4或更高版本,但是react-dnd 4指出它需要React 16.3或更高版本。运行npm install时,您应该已经看到这样的警告:

npm WARN react-dnd@4.0.0 requires a peer of react@>= 16.3 but none is installed. You must install peer dependencies yourself.

我希望您可能会在运行时遇到不兼容以及类型检查的问题。尝试使用react-dnd版本3.0.2。