-
Notifications
You must be signed in to change notification settings - Fork 539
feat(hitsPerPage): implement getRenderState
and getWidgetRenderState
#4532
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
feat(hitsPerPage): implement getRenderState
and getWidgetRenderState
#4532
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit ac85f2f:
|
getRenderState
and getWidgetRenderState
…ortcuts/instantsearch.js into feat/getWidgetRenderState-hitsPerPage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like a good start! I haven't read the tests yet, seems like they don't run for external PRs, so we need to see them manually
…oved `createURLFactory` in `getWidgetRenderState`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good job so far!
connectorState.createURLFactory = helperState => value => { | ||
return createURL( | ||
helperState.setQueryParameter( | ||
'hitsPerPage', | ||
!value && value !== 0 ? undefined : value | ||
) | ||
); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this function should probably stay in init for consistency with connectorState.setHitsPerPage, but I'm not sure how other connectors dealt with this yet
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. It can stay in init
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't able to keep it in init
because I got a createURLFactory is not a function
error due to getWidgetRenderState
getting called before init
, which is weird because there's no such issues with the other widgets (it looks like). Could you check my new update @eunjae-lee ? We checked with @Haroenv to see if there was an alternative but this was the only workaround that worked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
basically the problem is that in the test (similar to breadcrumb) it seems to call getWidgetRenderState before init has happened, which means it will throw, since connectorState is still empty object at that point
…HitsPerPage` initialization inside `getWidgetRenderState`
…ortcuts/instantsearch.js into feat/getWidgetRenderState-hitsPerPage
…HitsPerPage` initialization inside `getWidgetRenderState`
@Haroenv @shortcuts
I pushed my commit to show you for discussion, so we can drop it if we decide to go for the previous implementation. |
As I'm not that familiar with the logic behind the connectorState, your approach seems cleaner if we want to update widgets later on or if we have the same issue with an other widget, and it's not that different to other widgets. |
your approach is the way to go as far as I can see @eunjae-lee, thanks! |
The test:watch yelled at me to add the object at L798 in connectHitsPerPage-test.ts so please if you have any advices or question about the code let me know