对象不是在react-sidenav上使用withRR4()的函数

时间:2018-12-20 17:35:26

标签: javascript reactjs sidenav

我正在尝试使用react-sidenav而不是https://codesandbox.io/s/q9851xoymj来构建东西。

当我尝试使用该示例中的withRR4()函数时,加载页面时出现以下错误。 Object(...) is not a function,它发生在const SideNav = withRR4()

我正在使用"react-sidenav": "^3.1.3"

import React from 'react';
import { connect } from 'react-redux';
import { FaTasks, FaUserCog, FaProjectDiagram } from 'react-icons/fa';
import { IoIosBusiness } from 'react-icons/io';

import '../css/Nav.css';

import { withRR4, Nav } from 'react-sidenav';
import { Link } from "./styles";
import { getCompanies, getProjects, getTasks, getUsers } from '../actions';

const mapDispatchToProps = {
     getCompanies: getCompanies,
     getProjects: getProjects,
     getTasks: getTasks,
     getUsers: getUsers,
};

const SideNav = withRR4();

let CompanyLink=({getCompanies})=>(
   <Link onClick={getCompanies}><IoIosBusiness /> Companies</Link>
)
CompanyLink = connect(null,mapDispatchToProps)(CompanyLink);

let ProjectLink=({getProjects})=>(
   <Link onClick={getProjects}><FaProjectDiagram /> Projects</Link>
)
ProjectLink = connect(null,mapDispatchToProps)(ProjectLink);

let TaskLink=({getTasks})=>(
   <Link onClick={getTasks}><FaTasks /> Tasks</Link>
)
TaskLink = connect(null,mapDispatchToProps)(TaskLink);

let UserLink=({getUsers})=>(
   <Link onClick={getUsers}><FaUserCog /> Users</Link>
)
UserLink = connect(null,mapDispatchToProps)(UserLink);

const LeftNav = () => (
  <SideNav defaultSelectedPath="company">
     <Nav id="company"><CompanyLink /></Nav>
     <Nav id="projects"><ProjectLink /></Nav>
     <Nav id="tasks"><TaskLink /></Nav>
     <Nav id="users"><UserLink /></Nav>
   </SideNav>
)

export default LeftNav;

我不确定我在这里想念什么。

2 个答案:

答案 0 :(得分:0)

尝试使用其他版本:“ react-sidenav”:“ 3.0.9”

如果将版本升级到此版本以上,该示例也将不起作用。

答案 1 :(得分:0)

无需降级,请尝试以下操作:

import { withRR4 } from "react-sidenav/withRR4";