Open
Conversation
AlanCantabrana
commented
Apr 15, 2021

added 10 commits
March 19, 2021 21:09
PacoMojica
reviewed
Apr 18, 2021
PacoMojica
left a comment
There was a problem hiding this comment.
Hi Alan, you already have some things required for the next delivery, your challenge is looking good, great work!
Acceptance Criteria
- The search term is stored and retrieved from the Global Context correctly.
- The appearance theme is stored on the Global Context and applied correctly to the App UI.
-
useReducerhook is implemented correctly to manage the Global State.
Bonus Points
- Testing coverage is above 70%. (Please include a screenshot of the code coverage report in your PR description).
Comment on lines
+5
to
+30
| const GlobalContext = createContext(); | ||
|
|
||
| const useGlobalProvider = () => { | ||
| const context = useContext(GlobalContext); | ||
| if (!context) { | ||
| throw new Error(`Can't use "useGlobal" without an GlobalProvider!`); | ||
| } | ||
| return context; | ||
| }; | ||
|
|
||
| function GlobalProvider({ children }) { | ||
| const [state, dispatch] = useReducer(globalReducer, initialState); | ||
|
|
||
| useEffect(() => { | ||
| window.localStorage.setItem('theme', state.themeValue); | ||
| }, [state.themeValue]); | ||
|
|
||
| return ( | ||
| <GlobalContext.Provider value={{ state, dispatch }}> | ||
| {children} | ||
| </GlobalContext.Provider> | ||
| ); | ||
| } | ||
|
|
||
| export { useGlobalProvider, GlobalContext }; | ||
| export default GlobalProvider; |
There was a problem hiding this comment.
Awesome, the actions and the reducer is well defined, good stuff
Comment on lines
+4
to
+10
| SWITCH_THEME: 'SWITCH_THEME', | ||
| UPDATE_SEARCH_VALUE: 'UPDATE_SEARCH_VALUE', | ||
| SELECT_VIDEO: 'SELECT_VIDEO', | ||
|
|
||
| GET_VIDEOS_REQUEST: 'GET_VIDEOS_REQUEST', | ||
| GET_VIDEOS_SUCCESS: 'GET_VIDEOS_SUCCESS', | ||
| GET_VIDEOS_FAILURE: 'GET_VIDEOS_FAILURE', |
There was a problem hiding this comment.
I like that you defined the actions as constants 👍
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.