SIGN IN

React Lessons. Lesson 4. Homework.

Stay Informed

It's important to keep up
with industry - subscribe!

Stay Informed

Looks good!
Please enter correct name
Please enter correct email
Looks good!

a2a2543d-1502-4fac-9336-8f9627510105
Let’s talk about our homework. We shall notice, that in development of decorators / mixins all of logic in most cases work perfectly. It was implemented by us in the class. To complete our homework, the last thing that needs to be done is to put this logic into decorator and mixin. So that’s how our decorator will look like (src/decorators/oneOpen.js):

Decorators and mixins created to allow you to reuse your code, other words writing it once you will be able to use it in different places. What works today for articles will work tomorrow for comments, the authors or whatever. Therefore, when assigning the names of your entities create more universal (abstract) names. For example: openItem, openElement. To complete an optional part of our homework is enough to compare our received id with one we’ve  kept in the state. If so, this means that we need to close the article, to do this we can simply assign it to null, otherwise we’ll just change the id:

Our mixin (src/mixins/oneOpen.js) will be as follows:

Also ArticleList.js will be changed the following way:

ArticleListOld.js will look like this:

Please add following inscription in app.js, and delete import  of an  ArticleList:

Please compare our code with yours, and we will go further. Please check this repository for the right commits.

435258_8a75_3

We are looking forward to meeting you on our website soshace.com

About the author

Stay Informed

It's important to keep up
with industry - subscribe!

Stay Informed

Looks good!
Please enter correct name
Please enter correct email
Looks good!

Related articles

The Path of the Self-Taught Programmer: Avoiding Common Problems

In this article, we’ll explore how a self-taught programmer comes to be: which education opportunities they can utilize, which problems they may>>>

Programming

Introduction to GitHub Desktop: A GUI Enhancement to a CLI Approach

In this article, we'll explore various use cases of GitHub Desktop -- GUI software designed to ehance your git workflow. Does it hold up against CLI>>>

Programming
29.10.2019

Python Array Explained and Visualized

In this tutorial, we’ll delve into how Python arrays work, what their limitations are, and how you can use them to maximize their>>>

Programming

Sign in

Forgot password?

Or use a social network account

 

By Signing In \ Signing Up, you agree to our privacy policy

Password recovery

You can also try to

Or use a social network account

 

By Signing In \ Signing Up, you agree to our privacy policy