From 0c731c7498ebe014135369df1dc24a287a5816aa Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Tue, 25 May 2021 09:49:13 +1000 Subject: [PATCH] GroupFeedHeader: do not mutate state --- .../landscape/components/Home/GroupFeedHeader.tsx | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/pkg/interface/src/views/landscape/components/Home/GroupFeedHeader.tsx b/pkg/interface/src/views/landscape/components/Home/GroupFeedHeader.tsx index ece62533d..d0dd80e01 100644 --- a/pkg/interface/src/views/landscape/components/Home/GroupFeedHeader.tsx +++ b/pkg/interface/src/views/landscape/components/Home/GroupFeedHeader.tsx @@ -6,16 +6,14 @@ import React, { } from 'react'; export function GroupFeedHeader(props) { - const { baseUrl, history, graphResource, vip } = props; + const { baseUrl, history, vip } = props; let graph = props.graph; const historyLocation = history.location.pathname; - const graphId = `${graphResource.ship.slice(1)}/${graphResource.name}`; const [locationList, setLocationList] = useState([]); useEffect(() => { - locationList.push(history.location.pathname); - setLocationList(locationList); + setLocationList(ls => [...ls, history.location.pathname]); }, [history.location.pathname]); const isHome = @@ -32,7 +30,7 @@ export function GroupFeedHeader(props) { indicator = splitLoc[0]; } - const nodeIndex = splitLoc.slice(1).map((ind) => bigInt(ind)); + const nodeIndex = splitLoc.slice(1).map(ind => bigInt(ind)); let node; nodeIndex.forEach((i) => { @@ -70,7 +68,8 @@ export function GroupFeedHeader(props) { > { ( baseUrl !== historyLocation ) ? ( - { + { let loc = history.location.pathname.replace(`${baseUrl}`, '').split('/'); loc.pop(); @@ -96,7 +95,7 @@ export function GroupFeedHeader(props) { Group Feed {permText} - ) : ( !!authorText ? ( + ) : ( authorText ? ( <> Post by {`~${authorText}`}