const [inputVal, setInputVal] = useState("");
const [text, setText] = useState("");
const {
data,
refetch,
// etc
} = useGetPostsPaginated({ text }); // this is a tRPC query
useEffect(() => {
if (text.length > 0) {
refetch();
}
}, [text, refetch]);
function handleSearch(e: React.FormEvent) {
e.preventDefault();
setText(inputVal);
}
return (
<>
<form onSubmit={handleSearch}>
<input value={inputVal} onChange={e => stInputVal(e.target.value)} />
<button>Submit</button>
</form>
{data && <pre>{JSON.stringify(data, null, 2)}</pre>}
</>
)
const [inputVal, setInputVal] = useState("");
const [text, setText] = useState("");
const {
data,
refetch,
// etc
} = useGetPostsPaginated({ text }); // this is a tRPC query
useEffect(() => {
if (text.length > 0) {
refetch();
}
}, [text, refetch]);
function handleSearch(e: React.FormEvent) {
e.preventDefault();
setText(inputVal);
}
return (
<>
<form onSubmit={handleSearch}>
<input value={inputVal} onChange={e => stInputVal(e.target.value)} />
<button>Submit</button>
</form>
{data && <pre>{JSON.stringify(data, null, 2)}</pre>}
</>
)