Skip to content

Commit 673181b

Browse files
committed
fix empty search results bug
1 parent de95668 commit 673181b

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

client/pages/search/[[...query]].js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState } from "react";
1+
import React, { useState, useEffect } from "react";
22
import getConfig from "next/config";
33
import { useRouter } from "next/router";
44
import qs from "qs";
@@ -11,7 +11,11 @@ import Box from "../../components/Box";
1111
import TorrentList from "../../components/TorrentList";
1212

1313
const Search = ({ results, error, token }) => {
14-
const [torrents, setTorrents] = useState(results?.torrents ?? []);
14+
const [torrents, setTorrents] = useState([]);
15+
16+
useEffect(() => {
17+
setTorrents(results?.torrents ?? []);
18+
}, [results?.total]);
1519

1620
const router = useRouter();
1721
let {

0 commit comments

Comments
 (0)