mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(home): fix rerender with useEffect dep
This commit is contained in:
@@ -64,7 +64,10 @@ const Home = () => {
|
||||
const sfwAddresses = defaultSubplebbits.map((subplebbit) => subplebbit.address);
|
||||
const sfwSubs = useSubplebbits({ subplebbitAddresses: sfwAddresses });
|
||||
const sfwList = sfwSubs.subplebbits.map((subplebbit) => subplebbit?.address);
|
||||
const subplebbitToCid = {};
|
||||
const [sfwListCids, setSfwListCids] = useState([]);
|
||||
|
||||
useEffect(() => {
|
||||
let subplebbitToCid = {};
|
||||
|
||||
sfwSubs.subplebbits.forEach((s) => {
|
||||
let maxTimestamp = -Infinity;
|
||||
@@ -101,14 +104,16 @@ const Home = () => {
|
||||
}
|
||||
});
|
||||
|
||||
const sfwListCids = Object.values(subplebbitToCid)
|
||||
const newSfwListCids = Object.values(subplebbitToCid)
|
||||
.sort((a, b) => b.timestamp - a.timestamp)
|
||||
.map((item) => item.cid)
|
||||
.slice(0, 8);
|
||||
|
||||
setSfwListCids(newSfwListCids);
|
||||
}, [sfwSubs.subplebbits]);
|
||||
|
||||
const account = useAccount();
|
||||
const navigate = useNavigate();
|
||||
const isElectron = window.electron && window.electron.isElectron;
|
||||
|
||||
const inputRef = useRef(null);
|
||||
const prevStyle = useRef(selectedStyle);
|
||||
|
||||
Reference in New Issue
Block a user