Skip to content

Conversation

@VarunMotiyani
Copy link
Contributor

Fixes #issue-number

Changes:

I have verified that this pull request:

  • has no linting errors (npm run lint)
  • has no test errors (npm run test)
  • is from a uniquely-named feature branch and is up to date with the develop branch.
  • is descriptively named and links to an issue number, i.e. Fixes #123

@welcome
Copy link

welcome bot commented Sep 13, 2023

🎉 Thanks for opening this pull request! Please check out our contributing guidelines if you haven't already.

Comment on lines +35 to +37
useEffect(() => {
setSearchValue(searchTerm);
}, [searchTerm]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm really thinking through this effect as I go back and forth on whether it's good or bad. You're the only one who thought to include this here are we didn't have this logic in the class component version. It definitely shows a lot of foresight on your part to think about this 👍.

The situation where the searchTerm props changes based on some external factor doesn't come up in practice with the way that we are currently using the Searchbar component, as all changes are initiated by the component itself. But I'm all about separation of concerns and designing flexible and reusable components. The current component has the limitation that it will ignore any changes to searchTerm after mount and you've removed that limitation.

The main reason that I'm hesitating is a fear that this might interact badly with the throttle. I constantly have to remind myself of the difference between debounce and throttle so maybe it's not an issue. I'm concerned that there might be some pending changes which haven't been submitted at the time that searchTerm prop gets updated. Like if I'm trying to type "abc def" and the throttled submit goes through with "abc" but in the meantime I've typed " def" but now it's reset back to "abc". I'm not sure if that could happen.

@raclim raclim added the Area: Code Quality For refactoring, cleanup, or improvements to maintainability label Jan 26, 2024
Copy link
Collaborator

@raclim raclim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your work on this, this seems okay to me so far!

@raclim raclim merged commit 95c167f into processing:develop Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Code Quality For refactoring, cleanup, or improvements to maintainability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants