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

TypeError: Object(...) is not a function #13

Closed
ShadyXV opened this issue Dec 27, 2017 · 9 comments
Closed

TypeError: Object(...) is not a function #13

ShadyXV opened this issue Dec 27, 2017 · 9 comments
Assignees
Labels

Comments

@ShadyXV
Copy link

ShadyXV commented Dec 27, 2017

I am trying use this package but I am
getting this error when I try to run the code you have posted in the Example.
screenshot-2017-12-27 honeyguide apps
I am importing Breadcrumbs and rendering <Breadcrumbs/>. Is this not the way to do it?

@icd2k3
Copy link
Owner

icd2k3 commented Dec 27, 2017

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!

@icd2k3 icd2k3 self-assigned this Dec 27, 2017
@ShadyXV
Copy link
Author

ShadyXV commented Dec 27, 2017

Thank you for responding so quickly.Here is the full error detail.
screenshot-2017-12-27 honeyguide apps 1
I am not passing any props to Breadcrumbs is this where i am going wrong.

@icd2k3
Copy link
Owner

icd2k3 commented Dec 27, 2017

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

@ShadyXV
Copy link
Author

ShadyXV commented Dec 27, 2017

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);

@ShadyXV
Copy link
Author

ShadyXV commented Dec 27, 2017

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

@icd2k3
Copy link
Owner

icd2k3 commented Dec 27, 2017

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?

@ShadyXV
Copy link
Author

ShadyXV commented Dec 27, 2017

Yup. You are right.It's working now.Thank you.
I'll use react-router-breadcrumbs-hoc@1.0.7 for now.
Happy Holidays!

@icd2k3
Copy link
Owner

icd2k3 commented Dec 30, 2017

Thanks @ShadyXV I was able to repro your issue using create-react-app myself. I'll look into fixing the issue and close this thread with v 1.1.1 when fixed!

Edit: pinging @mhelmer who might have some suggestions here.

icd2k3 added a commit that referenced this issue Dec 30, 2017
Fixes issue #13 by getting rid of .mjs extension
@icd2k3
Copy link
Owner

icd2k3 commented Dec 30, 2017

This one took a while to figure out, but seems the create-react-app config has trouble with .mjs file extensions. I've changed the build output in v 1.1.1 here: #14

This should fix the issue, can you confirm on your end everything is still working @ShadyXV after upgrading from 1.0.7 to 1.1.1?

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

No branches or pull requests

2 participants