Skip to content

Commit

Permalink
Resolves react warning in console
Browse files Browse the repository at this point in the history
See openedx#291

As an aside, it's worth noting these files are practically the same, and with very little effort could be refactored into one in the spirit of DRY-ness.
  • Loading branch information
rediris committed Feb 13, 2024
1 parent 73ed886 commit 13a8bb3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
17 changes: 14 additions & 3 deletions src/containers/WidgetContainers/LoadedSidebar/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,21 @@ import hooks from 'widgets/ProductRecommendations/hooks';
export const WidgetSidebar = ({ setSidebarShowing }) => {
const { inRecommendationsVariant, isExperimentActive } = hooks.useShowRecommendationsFooter();

if (!inRecommendationsVariant && isExperimentActive) {
setSidebarShowing(true);
React.useEffect(() => {
if (!inRecommendationsVariant && isExperimentActive) {
setSidebarShowing(true);
return (
<div className="widget-sidebar">
<div className="d-flex flex-column">
<RecommendationsPanel />
</div>
</div>
);
}
return null;
}, [inRecommendationsVariant, isExperimentActive, setSidebarShowing]);

if (!inRecommendationsVariant && isExperimentActive) {
return (
<div className="widget-sidebar">
<div className="d-flex flex-column">
Expand All @@ -18,7 +30,6 @@ export const WidgetSidebar = ({ setSidebarShowing }) => {
</div>
);
}

return null;
};

Expand Down
17 changes: 14 additions & 3 deletions src/containers/WidgetContainers/NoCoursesSidebar/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,21 @@ import hooks from 'widgets/ProductRecommendations/hooks';
export const WidgetSidebar = ({ setSidebarShowing }) => {
const { inRecommendationsVariant, isExperimentActive } = hooks.useShowRecommendationsFooter();

if (!inRecommendationsVariant && isExperimentActive) {
setSidebarShowing(true);
React.useEffect(() => {
if (!inRecommendationsVariant && isExperimentActive) {
setSidebarShowing(true);
return (
<div className="widget-sidebar px-2">
<div className="d-flex">
<RecommendationsPanel />
</div>
</div>
);
}
return null;
}, [inRecommendationsVariant, isExperimentActive, setSidebarShowing]);

if (!inRecommendationsVariant && isExperimentActive) {
return (
<div className="widget-sidebar px-2">
<div className="d-flex">
Expand All @@ -18,7 +30,6 @@ export const WidgetSidebar = ({ setSidebarShowing }) => {
</div>
);
}

return null;
};

Expand Down

0 comments on commit 13a8bb3

Please sign in to comment.