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
Redux Challenges #3
Comments
There are two video series on YouTube that covers Redux in the context of a real-life app There is also this list about all things redux. Would we want to cover asynchronous stores (e.g. |
Here's a potential list of challenges:
Source: Redux Docs Thanks @EliBei for helping with finalizing these. |
@alayek this looks solid. @BerkeleyTrue has been extremely busy, and is fighting the flu. @BerkeleyTrue what do you think of this list? |
What about generating containers with |
@Em-Ant maybe we can cover that in React-Redux? |
@QuincyLarson Looks good. @Em-Ant Yes that would be covered in react-redux |
@alayek have we made any progress on these Redux challenges? As I said on the React thread, we can now use JSX on beta (staging) so you should be able to finish these. @BerkeleyTrue is working on the multi-tab editor, but we should assume it won't be ready in time for launch, and that these will need to be in script within the same single code editor as style and HTML elements. |
@alayek your list of topics has @BerkeleyTrue's approval. What else can we do to help get this going. Do you have anyone in mind whom we can delegate this to if you're too busy this week with work (and the React challenges 😄 )? |
@QuincyLarson thanks! I am in touch with elibei and he has been helping me a lot with the challenges. But we might need one more person to help us out with this, if we are to complete and have them production-ready by EOW. @t3h2mas up for it? |
Learn about Action Types
Action type
Example action typeSince an action type is a string constant, here is an example action type for an action that would add a todo item to a todo list.
InstructionsMake an action type constant. Create a Challenge Seed
Challenge Solution
Challenge Tests
|
Example of a Redux Action Object
The exampleImagine we have a Todo List application. An action for the application may be to add a todo item. Let's look at an example redux action for this task.
Let's create another Action for our todo app. InstructionsCreate an action object that will toggle the completed status of our example todo item. Start out by making an Action object with the type of Then assign an Challenge Seed
Challenge Solution
Challenge Tests
|
@alayek @BerkeleyTrue Can I suggest an Action Creator challenge as well? Action Creators are simple functions that return an action. They are used to dispatch, and later, to connect redux and react. |
Make an Action with an Action Creator
ExampleHere is an example action creator for our
Let's create an Action Creator for our InstructionsCreate a function named Challenge Seed
Challenge Solution
Challenge Tests
|
Write your first reducerSo far we've talked about Redux Actions. Actions describe that an action accured. They don't describe how the state changes as a result of that action. That is the Reducer's job. DescriptionA reducer is a pure function that takes the previous state as well as an action as arguments and returns the new state. In the simplest form a Reducer can look like
At this point a reducer wouldn't be any help. A reducer applies an action to state and returns a new state. Example counting app ReducerApp descriptionOur example app will be able to increment (action) and decrement (action) our count (state) number by 1. Incrementing the number
A few things to notice...
InstructionsAmend the reducer to handle DECREMENT action. Challenge Seed
Challenge Solution
Challenge Tests
|
@t3h2mas thanks!! Yes, please add an action creator challenge where you think would fit best. |
Use the Store to bring it all togetherThe object that brings it all together. The store is the single source of truth for all application state. Responsilities of the store
Creating a store with
|
Dispatch a Redux ActionApplying what we've learned so far. Actions? Remember those? It's time to put them to use using What we have so farIn the last challenge we finished with the following code
InstructionsOur code has been updated with Use Challenge Seed
Challenge Solution
Challenge Tests
|
[WIP]Question: Any suggestions on a test for this one?Subscribe to an ActionDo something everytime an action is dispatched. You can subscribe to state changes with the Example subscriptionLog the state to the console everytime an action is dispatched.
Unsubscribing
The challengeDispatch at least one Challenge Seed
Challenge Solution
Challenge TestsRegex to decide whether the action was dispatched
and to test for
|
@t3h2mas these challenges are off to a great start. I'm going to talk with @BerkeleyTrue about getting a proof of concept working with Enzyme. In the mean time, keep up the hard work on these. I updated my original post with a checklist of challenges. If you have a moment, since you know more about Redux than I do, perhaps you can come up with good names for these challenges that conform with our [Verb] [Object] structure (such as "Use an Action Payload as an Object") My goal is to answer any questions you may have and clear up any ambiguities so you can keep moving forward with designing these challenges. |
@QuincyLarson the (pure) Redux challenges should be testable w/ any assert testing function. I have tried to update the titles to match the verb object structure more but am open to feedback. My main question is how we can test the subscription and unsubscribe challenge. That one may require a regex or bootstrapped code... Right now I see the following incomplete from your lists. The rest looks to be covered.
The combining reducers task is an important one but the usefulness behind it may be overly complex until later on in learning/using redux. I will start writing a challenge for it all the same. |
@t3h2mas Awesome - I trust your judgement on this. Whatever you think is the best progression. You can ask @alayek @Em-Ant and @BerkeleyTrue if you need a second opinion - they know a lot more about React/Redux than I do :) |
I suggest we move Actions emitted by user interaction as well as combining reducers to the UPDATE: If someone can come up with a way to test store subscription, that would be cool. |
@t3h2mas That sounds good. I'm glad you're able to write tests for a lot of these. If you can't find a more elegant solution, I recommend going ahead with the dreaded regex tests :) |
Updated with two regexes. Will direct attention towards React tests. @QuincyLarson |
@ALL Please see the React Issues thread about an update we've made to the development of these React/Redux challenges. |
Thanks everyone! I'm closing this thread because our alpha React + Redux challenges are live. Read about them here: https://forum.freecodecamp.com/t/alpha-of-free-code-camps-react-redux-challenges-is-now-live/64492 |
@QuincyLarson It saddens me to see that all of the effort and time I spent writing the challenges in this issue seamed to have been tossed aside w/o communication. |
@t3h2mas That wasn't our intention here. Would you be interested in helping incorporate some of the challenges you designed into the new React+Redux challenges once we finish importing it? |
@alayek is in charge of coordinating the creation of these challenges, but he needs your help.
Here's a potential list of challenges:
Object.assign()
(state, action) => state
, must not modifystate
combineReducer()
getState()
dispatch(action)
store.dispatch(action)
Source: Redux Docs
Thanks @EliBei for helping with finalizing these.
Here are the challenges we have currently planned:
For each challenge, please reply to this GitHub issue with:
The text was updated successfully, but these errors were encountered: