TypeError: Object(...) is not a function
Closed this issue · 9 comments
Hey @ShadyXV could you please post your full source code for the file you're using the HOC in? Also, showing the full error details ("15 stack frames were collapsed") could help.
I'm on vacation currently, but should have time to check on this during my travels.
Thanks!
The hoc will automatically pass a breadcrumbs
prop into the wrapped component. You can pass additional props if you like, but it shouldn't matter in terms of rendering. When you have a moment could you paste the full source of Breadcrumbs/index.jsx
? Thanks
Breadcrumbs/index.jsx
looks like this
import React from "react";
import { NavLink } from "react-router-dom";
import { withBreadcrumbs } from "react-router-breadcrumbs-hoc";
const UserBreadcrumb = ({ match }) => <span>{match.params.userId}</span>; // use match param userId to fetch/display user name
const routes = [
{ path: "/", breadcrumb: "Home" },
{ path: "users", breadcrumb: "Users" },
{ path: "users/:userId", breadcrumb: UserBreadcrumb },
{ path: "something-else", breadcrumb: ":)" }
];
const Breadcrumbs = ({ breadcrumbs }) => (
<div>
{breadcrumbs.map(({ breadcrumb, path, match }) => (
<span key={path}>
<NavLink to={match.url}>{breadcrumb}</NavLink>
<span>/</span>
</span>
))}
</div>
);
export default withBreadcrumbs(routes)(Breadcrumbs);
I trying rendering Breadcrumbs in different ways but even just importing it fails with the same errors.
I am importing Breadcrumbs from Breadcrumbs/index.jsx like so
import Breadcrumbs from './components/Breadcrumbs';
i am using this in a create-react-app project, react v16.2.0, react-router-dom v4.2.2
Hey @ShadyXV I'll have to take a closer look at this in the near future. Not quite sure what might be happening as of yet.
The build process recently switched (PR: #9) ... I wonder if there is possibly some unintended side effects from that. Could you try downgrading npm i react-router-breadcrumbs-hoc@1.0.7
and see if that fixes the issue?
Yup. You are right.It's working now.Thank you.
I'll use react-router-breadcrumbs-hoc@1.0.7 for now.
Happy Holidays!