-
Notifications
You must be signed in to change notification settings - Fork 3
[CSL-3053] Zero state recommendations a/b support #129
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
[CSL-3053] Zero state recommendations a/b support #129
Conversation
src/hooks/useSections.ts
Outdated
| if (zeroStateActiveSections && podsData && Object.keys(podsData).length) { | ||
| const features = getSearchSuggestionFeatures(Object.values(podsData)[0]); | ||
| if (features.featureDisplayZeroStateRecommendations) { | ||
| activeSections.length = 0; |
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.
Not too sure I like what I'm doing here.
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.
there could be side effects when setting activeSections.length = 0 since it modifies the original array. you might want to have immutability for cleaner and predictable code.
consider this scenario
const sections = [a,b,c];
console.log(sections) // prints [a,b,c]
const {...} = useSections(query, cioClient, sections);
// it runs `activeSections.length = 0`
console.log(sections) /// prints []
off the top of my head, you could instead do
const [activeSections, setActiveSections] = useState(zeroStateActiveSections ? zeroStateSections : sections);
useEffect(() => {
// Delete active sections if feature toggle, zeroStateActiveSessions is present
if (...) {
setActiveSections([]);
}
}, [zeroStateActiveSections, podsData, getSearchSuggestionFeatures])
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.
Thanks, that definitely conforms to the react pattern better.
esezen
left a comment
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.
This is looking good. I left a few comments, let me know what you think
esezen
left a comment
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.
LGTM! I think the tests are failing because we have the feature toggle on. Can you turn the toggle of and run tests on the PR before you merge?
No description provided.