atapas / webapis-playground

The Web APIs Playground is a project to showcase the JavaScript Web APIs with examples and demonstrations. Client-side JavaScript APIs are here to help with providing wrapper functions for many low-level tasks.

Home Page:https://webapis-playground.vercel.app/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Improvement] replace currenct searchApi method with hook

rzhekova opened this issue · comments

Currently eslint flags a warning on the SearchBox component due to useEffect missing onSearch from its dependency array. When you add it to the array, the search finctionality on the website breaks due to an infinite re-render. Potentially this happens because we end up with a circular new objects creation by triggering the filter array method within SearchBox.

Replacing this function with a hook that gets called in the parent component (App) fixes this issue. I will raise a PR for this.