fix channels list rerender

This commit is contained in:
Guillaume Dorce 2024-01-12 15:38:34 +01:00
parent bec2d73114
commit fd9f4cac65
1 changed files with 7 additions and 5 deletions

View File

@ -1,15 +1,17 @@
import { FaCog } from "react-icons/fa"; import { FaCog } from "react-icons/fa";
import { Pb } from "../../EspaceMembres"; import { Pb } from "../../EspaceMembres";
import { useContext, useState } from "preact/hooks"; import { useContext, useEffect, useState } from "preact/hooks";
import type { ChannelsRecord } from "../../../types/pb_types"; import type { ChannelsRecord } from "../../../types/pb_types";
export default function Channels() { export default function Channels() {
const pb = useContext(Pb); const pb = useContext(Pb);
const [channels, setChannels] = useState<Array<ChannelsRecord>>([]); const [channels, setChannels] = useState<Array<ChannelsRecord>>([]);
useEffect(() => {
pb.collection('channels').getFullList<ChannelsRecord>().then((data) => { pb.collection('channels').getFullList<ChannelsRecord>().then((data) => {
if (!data) return; if (!data) return;
setChannels(data); setChannels(data);
}); });
}, []);
return ( return (
<div className="flex flex-col flex-grow border-b-2 border-b-gray-200"> <div className="flex flex-col flex-grow border-b-2 border-b-gray-200">