Merge pull request #8939 from mabashian/8937-org-tabs-requests

Wrap breadcrumb function in useCallback to prevent infinite requests on org tabs

Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
softwarefactory-project-zuul[bot] 2020-12-17 15:49:56 +00:00 committed by GitHub
commit e08e88d940
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,4 @@
import React, { useState, Fragment } from 'react';
import React, { useCallback, useState, Fragment } from 'react';
import { Route, withRouter, Switch, useRouteMatch } from 'react-router-dom';
import { withI18n } from '@lingui/react';
import { t } from '@lingui/macro';
@ -17,25 +17,28 @@ function Organizations({ i18n }) {
'/organizations/add': i18n._(t`Create New Organization`),
});
const setBreadcrumb = organization => {
if (!organization) {
return;
}
const setBreadcrumb = useCallback(
organization => {
if (!organization) {
return;
}
const breadcrumb = {
'/organizations': i18n._(t`Organizations`),
'/organizations/add': i18n._(t`Create New Organization`),
[`/organizations/${organization.id}`]: `${organization.name}`,
[`/organizations/${organization.id}/edit`]: i18n._(t`Edit Details`),
[`/organizations/${organization.id}/details`]: i18n._(t`Details`),
[`/organizations/${organization.id}/access`]: i18n._(t`Access`),
[`/organizations/${organization.id}/teams`]: i18n._(t`Teams`),
[`/organizations/${organization.id}/notifications`]: i18n._(
t`Notifications`
),
};
setBreadcrumbConfig(breadcrumb);
};
const breadcrumb = {
'/organizations': i18n._(t`Organizations`),
'/organizations/add': i18n._(t`Create New Organization`),
[`/organizations/${organization.id}`]: `${organization.name}`,
[`/organizations/${organization.id}/edit`]: i18n._(t`Edit Details`),
[`/organizations/${organization.id}/details`]: i18n._(t`Details`),
[`/organizations/${organization.id}/access`]: i18n._(t`Access`),
[`/organizations/${organization.id}/teams`]: i18n._(t`Teams`),
[`/organizations/${organization.id}/notifications`]: i18n._(
t`Notifications`
),
};
setBreadcrumbConfig(breadcrumb);
},
[i18n]
);
return (
<Fragment>