I
I
Ilya Kolesnikov2021-08-04 01:43:12
React
Ilya Kolesnikov, 2021-08-04 01:43:12

How to make breadcrumbs with react-router-dom?

We use react-router-dom in the application, maybe there is an article or an example for implementation, I will be very grateful

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alice, 2021-08-04
@w3bsmes

Hold and hold

G
Gucciprado1337, 2021-08-04
@Gucciprado1337

Try this simple solution:

const Breadcrumbs = ({ ...rest, match }) => (
  <span>
      <Link to={match.url || ''} className={match.isExact ? 'breadcrumb active' : 'breadcrumb'}>
          {match.url.substr(match.url.lastIndexOf('/')+1, match.url.length)}
      </Link>
      <Route path={`${match.url}/:path`} component={Breadcrumbs} />
  </span>
)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question