Design comparison
SolutionDesign
Solution retrospective
What are you most proud of, and what would you do differently next time?
In this project, I learned to use different common react hooks.
a. useEffect to watch certain state and apply side effects like fetching API response or update other states
import { useEffect } from 'react';
useEffect(() => {
if (currentKeyword === '') return;
getVocabDefinition(currentKeyword);
}, [currentKeyword]);
b. useContext to provide context accross components. This hook is similar to the provide/inject syntax provided by Vue3
import { createContext, useContext } from 'react';
type TypeCurrentKeywordContext = {
currentKeyword: string;
handleSearch: (keyword: string) => void;
};
const CurrentKeywordContext = createContext(
null
);
const { handleSearch } = useContext(
CurrentKeywordContext
) as TypeCurrentKeywordContext;
I also tried Redux to manage the global state to toggle the app's dark/light theme
What specific areas of your project would you like help with?Any suggestions are welcomed. Thank you.
Community feedback
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord