Comments (11)
Your fix is working.
I deleted node_modules folder. Looks like it was caching the older version?. Something weird, but now it's showing the home breadcrumb.
Thank you
from react-router-breadcrumbs-hoc.
Hey @diegolaciar, thanks for the question!
I'll work on a patch to allow for the home root route in config.
For now, since it's probably expected that the Home breadcrumb would appear everywhere, you could just render one separately outside of the config. Using the readme example:
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: 'users', breadcrumb: 'Users' },
{ path: 'users/:userId', breadcrumb: UserBreadcrumb},
{ path: 'something-else', breadcrumb: ':)' },
];
const Breadcrumbs = ({ breadcrumbs }) => (
<div>
<NavLink to="/"}>Home</NavLink>/ // <----
{breadcrumbs.map(({ breadcrumb, path, match }) => (
<span key={path}>
<NavLink to={match.url}>
{breadcrumb}
</NavLink>
<span>/</span>
</span>
))}
</div>
);
I'll post back here when patch is complete
from react-router-breadcrumbs-hoc.
@diegolaciar I pushed a new version 1.0.3
to address this. You should now be able to use:
{ path: '/', breadcrumb: 'Home' }
In your config. Thanks again, and please let me know if you run into any other issues.
from react-router-breadcrumbs-hoc.
@icd2k3 I updated react-router-breadcrumbs-hoc ^1.0.2 → ^1.0.3
I tried again using :
{ path: '/', breadcrumb: 'Home' }
or
{ path: '', breadcrumb: 'Home' }
and i don´t get the home breadcrumb.
from react-router-breadcrumbs-hoc.
Looking into code could be something with my routes config.
All my routes are child from home route.
I can' t discover whats going on.
Anyway, thank you for you fix and fast response !
from react-router-breadcrumbs-hoc.
@diegolaciar my apologies, there was a problem with the compiled build published to npm (apparently prepublishOnly
doesn't work as I expected it to)
...anyways, this problem will be solved after upgrading the package 1.0.3
→ 1.0.5
Sorry for the inconvenience - please let me know if it fixes your issue
from react-router-breadcrumbs-hoc.
Hi @icd2k3,
I just updated react-router-breadcrumbs-hoc ^1.0.3 → ^1.0.5 and installed the pkg.
I have on the config
{ path: "/", breadcrumb: "Home" },
It looks like the issue persist.
Breadcrumbs render good and it shows all the routes I configured, but is not showing the "home" breadcrumb.
from react-router-breadcrumbs-hoc.
If I do
{ path: "", breadcrumb: "Home" },
Error: withBreadcrumbs: breadcrumb
and path
must be provided in every route object
So I just leave { path: "/", breadcrumb: "Home" },
from react-router-breadcrumbs-hoc.
{ path: "/", breadcrumb: "Home" }
should work (the path can't be blank).
Seems to be working OK on my end... Could you please provide the react
, react-router
, & react-router-dom
versions you're using?
Also, can you post your code from the component rendering your breadcrumbs?
Thanks!
from react-router-breadcrumbs-hoc.
"react": "^16.1.0",
"react-dom": "^16.1.0",
"react-router": "^4.2.0",
I cant push all the code but looks something like this.
import React, { Component } from "react";
import PropTypes from "prop-types";
import { withBreadcrumbs } from "react-router-breadcrumbs-hoc";
import NavigateNext from "material-ui-icons/NavigateNext";
import { Link, NavLink } from "react-router-dom";
const routes = [
{ path: "/", breadcrumb: "Home" },
{ path: "/users", breadcrumb: "Users" },
];
export class App extends Component {
static propTypes = {
children: PropTypes.node,
};
static defaultProps = {
children: "No content.",
};
render() {
const { breadcrumbs } = this.props;
return (
<div className="home-app">
<div className="page-container">
<Header />
<div>
{breadcrumbs.map(({ breadcrumb, path, match }, index) => (
<span key={path}>
{index < breadcrumbs.length - 1 ? (
<NavLink to={match.url}>{breadcrumb}</NavLink>
) : (
breadcrumb
)}
{!!(index < breadcrumbs.length - 1) && (
<span
style={{
verticalAlign: "sub",
}}
>
<NavigateNext
style={{
width: 16,
height: 16,
}}
/>
</span>
)}
</span>
))}
</div>
{this.props.children}
</div>
</div>
);
}
}
App = withBreadcrumbs(routes)(App);
export default App;
from react-router-breadcrumbs-hoc.
@diegolaciar good to hear! Please let me know if you run into any other issues.
from react-router-breadcrumbs-hoc.
Related Issues (20)
- Translated breadcrumbs (delaying routes init) HOT 1
- dassad
- Unnecessary peer dependency on react-router-dom HOT 4
- "//" produces double matches HOT 1
- Unable to pass additional props. HOT 3
- define breadcrumb‘s description HOT 2
- Disabling default generated breadcrumbs by passing breadcrumb: null raises an error HOT 2
- Property 'match' does not exist on type 'ReactNode' HOT 1
- What to use instead of InjectedProps HOT 3
- Replacing react-router with react-router-dom HOT 2
- Fixed
- Suppress autmatically added Home Breadcrumb HOT 2
- Issue with excludePaths not being consistent with breadcrumbs: null HOT 6
- Question about type definition HOT 3
- typescript definition mistake HOT 1
- How do I add in between crumbs ? HOT 2
- Question: Is there a way to not export the current page in breadcrumbs HOT 2
- Question: breadcrumbs propTypes HOT 1
- How to remove "-" from titles HOT 3
- react-router v6 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-router-breadcrumbs-hoc.