Skip to content

Commit

Permalink
#39 remove "displayedRepos" as property from Contributions
Browse files Browse the repository at this point in the history
  • Loading branch information
xeronimus committed Feb 7, 2022
1 parent 7c597d1 commit 6838bdd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function App() {
to: "/contributions",
component: <Contributions repos={contributions}
externalRepos={externalContributions}
displayedRepos={contributions.concat(externalContributions)}/>,
/>,
display: "Contributions"
},
{
Expand Down Expand Up @@ -85,7 +85,8 @@ function App() {
{ /* Main routable page content */}
<div ref={pageContentRef}>
<Routes>
{routes.map(route => <Route key={route.display} path={route.to} element={route.component}/>)}
{routes.map(route => <Route key={route.display} path={route.to}
element={route.component}/>)}
<Route path="/" element={defaultRoute.component}/>
</Routes>
</div>
Expand Down
5 changes: 2 additions & 3 deletions src/pages/Contributions/Contributions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import SearchBar from "../../components/SearchBar/SearchBar";
type Props = {
repos: RepoModel[]
externalRepos: RepoModel[];
displayedRepos: RepoModel[];
}

const byText = (text: string) => (repo: RepoModel) => text ? repo.name.toUpperCase().includes(text.toUpperCase())
Expand All @@ -18,7 +17,7 @@ const byStargazersCount = (a: RepoModel, b: RepoModel) => b.stargazers_count - a

const Contributions = (props: Props) => {

const [displayedRepos, setDisplayedRepos] = useState(props.displayedRepos);
const [displayedRepos, setDisplayedRepos] = useState<RepoModel[]>([]);
const [searchQuery, setSearchQuery] = useState('');

useEffect(() => {
Expand All @@ -27,7 +26,7 @@ const Contributions = (props: Props) => {
.filter(byText(searchQuery))
.sort(byStargazersCount)
);
}, [props.displayedRepos, searchQuery]);
}, [props.repos, props.externalRepos, searchQuery]);

return (
<div className="Contributions">
Expand Down

0 comments on commit 6838bdd

Please sign in to comment.