React, reuse a component

Honestly and really, I have been very hard to write code with Javascript without tool (IDE for example).

Now we will go to reuse a component (like_button.js). Again I have took an example from w3Schools (tables with bootstrap), with three famous and important characters.

We have here the code:

Bootstrap Table.

Section React…

We invoke the same class like_button_container but add a new attribute data-comment-id with values from 1 to 3, just to differentiate we have renamed the like_button.js for like_button2.js.

Code for React (like_button2.js).

Maybe the code is clear for some, but for others not so much. The comments help us to understand the logic of the code.

Then in the React site explain “This strategy is mostly useful while React-powered parts of the page are isolated from each other. React code, it’s easier to use component composition instead

Here the page with the second React example.


Teacher Miguel Araujo.

Deja un comentario