1

我正在尝试使用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;

我不确定我在这里缺少什么。

4

2 回答 2

0

尝试使用不同的版本:“react-sidenav”:“3.0.9”

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

于 2018-12-20T19:20:48.007 回答
0

无需降级,试试这个:

import { withRR4 } from "react-sidenav/withRR4";
于 2019-04-11T16:19:38.393 回答