FrontendChallenges is a collection of frontend interview questions and answers. It is designed to help you prepare for frontend interviews. It's free and open source.
Consider the app that renders a SearchBar component, which is memoized using React.memo. The SearchBar accepts an onSearch function as a prop to update the search query.
Can you answer the following:
The SearchBar is memoized using React.memo, yet it still re-renders every time the parent component updates. Why does this happen?
What is causing the memoization of SearchBar to fail, and how would you resolve the issue?
Modify the code so that SearchBar only re-renders when it truly needs to, without breaking the functionality of the search feature.
Template
styles.css
body {
font-family: sans-serif;
}
h1 {
font-size: 1.5rem;
}
Info
Question
Consider the app that renders a SearchBar component, which is memoized using React.memo. The SearchBar accepts an onSearch function as a prop to update the search query.
Can you answer the following:
Template
styles.css
App.jsx
index.jsx
public/index.html
SearchBar.jsx