-
Notifications
You must be signed in to change notification settings - Fork 19
Redux refactoring #3
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: hooks
Are you sure you want to change the base?
Conversation
src/components/profile/Profile.js
Outdated
| //const [profile, setProfile] = useState({}); | ||
|
|
||
| useEffect(() => { | ||
| axios.get(`https://api.github.com/user`).then((response) => { | ||
| setProfile(response.data); | ||
| }); | ||
| }); | ||
| const dispatch = useDispatch() | ||
| const userData = useSelector((state) => state.profile.userData) | ||
|
|
||
| useEffect(() => { | ||
| dispatch(fetchProfileData()) | ||
| // axios.get(`https://api.github.com/user`).then((response) => { | ||
| // setProfile(response.data); | ||
| // }); |
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.
outdated code would rather be deleted :trash:
| // const fetchRepos = () => { | ||
| // setRepos("loading"); | ||
| // axios | ||
| // .get("https://api.github.com/user/repos", { | ||
| // params: filters, | ||
| // }) | ||
| // .then((response) => { | ||
| // setRepos(response.data); | ||
| // }) | ||
| // .catch((error) => { | ||
| // console.log(error); | ||
| // setRepos([]); | ||
| // }); | ||
| // }; |
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.
Same for this. Leaving commented outdated code will affect code readability
src/store/actions/profile.action.js
Outdated
| const fetchProfileData = createAsyncThunk( | ||
| 'profile/fetchProfileData', | ||
| async () => { | ||
| const res = await axios.get('https://api.github.com/user') |
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.
Why don't we abstract the baseUrl https://api.github.com and make it an environment variable in .env
src/store/actions/repos.actions.js
Outdated
| const fetchRepos = createAsyncThunk( | ||
| 'repos/fetchRepos', | ||
| async () => { | ||
| const res = await axios.get('https://api.github.com/user/repos') |
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.
If we abstract the baseUrl and make it an environment variable we will directly use it here.
If for some reason, we or the thrid party (github) are changing the url, we will change it once
|
@Ikdemm I'll make sure to apply the fixes and commit right away ! |
Redux Store setup including :
🦇