Closed nkapolcs closed 4 years ago
For now, I display the same as the medium, but maybe we could use icons if you prefer.
On second thought, how about making the logic more "reactish"? :)
const [languageBadges, setLanguageBadges] = useState([]);
useEffect(() => {
if (githubRepoLanguages.data) {
const sum = Object.keys(githubRepoLanguages.data).reduce(...);
// filter the badges according to the treshold
const badges = // ...
setLanguageBadges(badges);
}
}, [githubRepoLanguages.data]);
Please make sure there's no infinite re-renders(because data
points to a reference). If so, let's use useMemo()
.
For now, I display the same as the medium, but maybe we could use icons if you prefer.
This should follow the display
setting.
On second thought, how about making the logic more "reactish"? :)
const [languageBadges, setLanguageBadges] = useState([]); useEffect(() => { if (githubRepoLanguages.data) { const sum = Object.keys(githubRepoLanguages.data).reduce(...); // filter the badges according to the treshold const badges = // ... setLanguageBadges(badges); } }, [githubRepoLanguages.data]);
Please make sure there's no infinite re-renders(because
data
points to a reference). If so, let's useuseMemo()
.
Thanks for suggesting. Now I solved it with hooks.
Resolved by a72c1f4
For now, I display the same as the medium, but maybe we could use icons if you prefer.
This should follow the
display
setting.
Resolved by a72c1f4
How about making this even simpler?
const languages = Object.keys(githubRepoLanguages.data).filter( language => { const currentNumberOfBytes = githubRepoLanguages.data[language]; return ( (currentNumberOfBytes / sumOfNumberOfBytesOfLanguages) * 100 > threshold ); } );
This way you don't need to iterate over the array twice.
Thanks!
Resolved by 0d74fcc
Issue #25
Currently GH project tech info in configurable by hand, but we could extend it so that it can auto-infer some things.
Changes:
Preview:![Peek 2020-03-09 23-24](https://user-images.githubusercontent.com/18705136/76262900-e3b51f00-625d-11ea-91e6-6ade50468da8.gif)