My solo project - We are the Champions (from The Frontend Developer Career Path of Scrimba)
Explore the docs »
View Demo
·
Report Bug
·
Request Feature
Table of Contents
My solo project - We are the Champions.
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 dev- Setup and ESLint, Prettier, Husky
- Setup UnoCSS
- Setup Font Awesome
- Setup Firebase
- Form to input fields
- Like feature (same card can only be liked by the same person for one time, same person can like many cards)
- Reverse cards order by created Date time (latest created card should be on the top)
- Setup and config PWA
- Refactor
- Manage firebase related files
- Lazy load cards on scrolling to view
- Firebase helpers
- Cache static components
See the open issues for a full list of proposed features (and known issues).
Extract childSnapshot from the snapshot object
const dataArray: EndorsementData[] = [];
snapshot.forEach(function (childSnapshot) {
const item = childSnapshot.val();
item.key = childSnapshot.key;
dataArray.push(item);
});
Uncaught Error: Too many re-renders. React limits the number of renders to prevent an infinite loop. When update state in onValue function of firebase
Wrap onValue in useEffect,
const [endorsementData, setEndorsementData] = useState<EndorsementData[]>([]);
...
useEffect(() => {
return onValue(endorsementsRef, (snapshot) => {
if (!snapshot.exists()) {
console.log("Cannot find snapshot");
return;
}
const dataArray: EndorsementData[] = [];
snapshot.forEach(function (childSnapshot) {
const item = childSnapshot.val();
item.key = childSnapshot.key;
dataArray.push(item);
});
setEndorsementData(dataArray);
});
}, []);
push boolean instead, make field likedBy to be false when the array is empty
export type EndorsementData = {
id: string;
from: string;
to: string;
text: string;
likedBy: string[] | boolean;
};
Distributed under the MIT License. See LICENSE.txt for more information.
Jen Chen
Project Link: https://github.com/yujhenchen/endorsements-react-vite-pwa-firebase