-
Notifications
You must be signed in to change notification settings - Fork 857
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
Develop #756
base: master
Are you sure you want to change the base?
Develop #756
Conversation
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 👍
let's improve your solution
export const App: React.FC = () => { | ||
const { name, born, died } = peopleFromServer[0]; | ||
const [chosenPerson, setChosenPerson] = useState<Person | null>(null); |
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.
export const App: FC = () => {
|
||
export const App: React.FC = () => { | ||
const { name, born, died } = peopleFromServer[0]; | ||
const [chosenPerson, setChosenPerson] = useState<Person | null>(null); | ||
const [appliedQuery, setAppliedQuery] = useState(''); |
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.
Rename appliedQuery
to searchQuery
for clearer intent. This enhances readability and aligns better with related variables in your codebase.
const [query, setQuery] = useState(''); | ||
const [isFocused, setIsFocused] = useState(false); | ||
|
||
const applyQuery = useCallback(debounce(changeAppliedQuery, delay), []); |
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.
you can include changeAppliedQuery and delay in the dependency array, this ensures that the debounce function updates correctly if changeAppliedQuery or delay changes.
const applyQuery = useCallback(debounce(changeAppliedQuery, delay), []); | |
const applyQuery = useCallback(debounce(changeAppliedQuery, delay), [changeAppliedQuery, delay]); |
DEMO LINK