My solo project - Color Scheme Generator (from The Frontend Developer Career Path of Scrimba)
Explore the docs »
View Demo
·
Report Bug
·
Request Feature
Table of Contents
My solo project - Color Scheme Generator.
This is an example of how you may give instructions on setting up your project locally. To get a local copy up and running follow these simple example steps.
Install packages
yarnLaunch at localhost in development mode
yarn start- Click to copy color to clipboard
See the open issues for a full list of proposed features (and known issues).
flex items-center justify-center
set self-stretch to the flex item
debounce
Root cause:
This is a caveat of function components. Local variables inside a function expires after every call. Every time the component is re-evaluated, the local variables gets initialized again.
debounce function in helper.js:
export default function debounce(func, timeout) {
let timer;
return (...args) => {
clearTimeout(timer);
timer = setTimeout(() => {
func(...args);
}, timeout);
};
}
Before
const hideToast = debounce(() => setShowToast(false), 2000);
After wrap the usage using useCallBack()
const hideToast = useCallback(
debounce(() => setShowToast(false), 2000),
[]
);
Distributed under the MIT License. See LICENSE.txt for more information.
Jen Chen
Project Link: https://github.com/yujhenchen/color-scheme-generator-react