-
Notifications
You must be signed in to change notification settings - Fork 19
Hooks2 #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: class-components
Are you sure you want to change the base?
Hooks2 #2
Conversation
| /*const fetchRepos = () => { | ||
| setRepo( "loading" ) | ||
| axios.get("https://api.github.com/user/repos", { | ||
| params: this.state.filters | ||
| params: filters | ||
| }) | ||
| .then((response) => { | ||
| this.setState({ repos: response.data }) | ||
| setRepo(response.data ) | ||
| }) | ||
| .catch((error) => { | ||
| console.log(error) | ||
| this.setState({ repos: [] }) | ||
| setRepo( [] ) | ||
| }) | ||
| } | ||
| }*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This outdated code is better removed to not affect code readability
| {/*<div className="repositoies-list-navigation-buttons-container"> | ||
| <button | ||
| onClick={this.handlePrevPage} | ||
| onClick={handlePrevPage} | ||
| className="repositoies-list-navigation-button" | ||
| disabled={this.state.filters.page === 1} | ||
| disabled={filters.page === 1} | ||
| > | ||
| {"<"} | ||
| </button> | ||
| <button | ||
| onClick={this.handleNextPage} | ||
| onClick={handleNextPage} | ||
| className="repositoies-list-navigation-button" | ||
| > | ||
| {">"} | ||
| </button> | ||
| </div> | ||
| </div>*/} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code as well
src/redux/store.js
Outdated
| @@ -0,0 +1,7 @@ | |||
| import rootReducer from "./reducers" | |||
| //import { createStore } from "@reduxjs/toolkit" | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this comment
src/redux/reducers/repos.reducer.js
Outdated
|
|
||
| const initialState = { | ||
| reposList: [], | ||
| filters:{page:1,per_page:10,visibility:"public"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
filters can stay in the local state of the component since it is not shared with any other.
If, for some reason, we needed to have them in the store, you should dispatch new actions and handle them in the reducer to update the data from the component.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you Sir for your comments, I tried to solve the bugs and update profile and repositoriesList using redux
eya26
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to update profile and repositoriesList using redux and it's working
No description provided.