-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pagination without safari component #432
Comments
Hi @AstaDK, have you tried the |
Tks for reply, but this example using component pagination, in my case I don't want to using it. |
FIY my version using |
You don't have to use the const { page, setPage, resultsPerPage, pageCount, totalResults } = usePagination();
return (
<div>
<div>Current page: {page}</div>
<div>
<button onClick={() => {setPage(1)}}>Go to page 1</button>
<button onClick={() => {setPage(2)}}>Go to page 2</button>
....
</div>
</div>
) Or maybe I misunderstood your question. Any further elaboration is very much appreciated. |
Cool, That all I need. |
Sr, I just find one point and want to ask you. After I setPage the request server called. But variable searching from useSearchContext not change, It mean the result do not update. The code:
The log not appear. The request server called but results not update |
@AstaDK although the
May I ask why the new versions do not work for you? |
It is indeed not updating the |
Im not sure but I was updated latest versions for all Sajari, but the filter option do not work fine, It have some issue and after I downgrade with the version present. |
Sorry, I'm not quite clear what you mean 😅 |
No problem, Can you update for me the latest stable versions? |
You can find the latest version of the packages in README.md. |
Tks, I will check with the latest version. If another issue, I will create a topic on this. |
edfd019 I think it change from true to false and response the results right? |
@AstaDK thanks for reporting. We'll check and fix it if it's an issue. |
@AstaDK Can you give me a codesandbox of the mentioned issue? I can't seem to be able to reproduce it locally. |
The codesandbox do not fully shown my case. But I don't use set Paging and used setQuery, it is okay. I don't know what a reason. const { setQuery } = useQuery();
const { variables } = useVariables()
const handleShowMore = () => {
// setPage(page + 1);
variables.set({
page: page + 1,
});
setQuery(textSearch);
}; But How I can set page inside variables and then I use setQuery to query with the new config variables I set |
https://github.com/AstaDK/Next-Sajari/tree/pagination |
Hi @AstaDK, I'll checkout your code whenever I got the time, thank you. |
Hi @AstaDK, your code seems to render multiple import { FilterBuilder, SearchProvider, Variables } from "@sajari/react-hooks";
import { useState } from "react";
import { pipelineConfig } from "../../config";
import ItemComponent from "../items";
const variables = new Variables({
resultsPerPage: 6,
q: ``,
});
const pipeline = pipelineConfig();
const HomeComponent = () => {
const [listViews, setListViews] = useState([
{
name: "Asta",
isRender: true,
text: "SanDisk",
},
{
name: "Nick",
isRender: true,
text: "HP",
},
{
name: "Deku",
isRender: true,
text: "Apple",
},
]);
const brandFilter = new FilterBuilder({
name: "brand",
options: listViews.reduce((acc, v) => {
acc[v.text] = `brand = '${v.text}'`;
return acc;
}, {}),
});
return (
<div className="space-y-6">
<SearchProvider
search={{
variables,
pipeline,
filters: [brandFilter],
}}
searchOnLoad={true}
>
{listViews &&
listViews
.filter((i) => i.isRender)
.map((item, index) => {
return (
<ItemComponent
listViews={listViews}
setListViews={setListViews}
item={item}
/>
);
})}
</SearchProvider>
</div>
);
};
export default HomeComponent; |
I try to move the provider to the top level but I still have the same issue above. |
I using sajari for my demo app.
I have 1 list and I want to show more items, I don't want to use the sajari component but I can't query after I change variables page.
I using useSearchContext to get page and results, I cover my component with component search provider, code example bellow:
<SearchProvider key="{index}" searchOnLoad={false} initialResponse="" search={{ pipeline: new Pipeline( { ...getConfigPipeline("") }, "query" ), variables: new Variables({ q: "", filter: "", resultsPerPage: 6, }), }} > <MyComponent/> </SearchProvider>
Render result
const { setQuery } = useQuery(); const { variables } = useVariables(); const { results, searching, totalResults, page, pageCount, } = useSearchContext();
And then I use variables hook(useVariables) to set request for other page but It not request, code example bellow:
const OtherComponent = ({ setQuery, textSearch, variables }) => { const handleShowMore = () => { variables.set({ page: page + 1, }); };
The text was updated successfully, but these errors were encountered: