Posts

Showing posts with the label Component Based Architecture

A Basic Intro Into Making React Components

Image
We have all been there; we are developing a page that is like another, so we copy an entire section of code from another page to add to our new page. This works, but now we just added another 500 lines of html to our already 1500-line page. Since we are the ones who wrote the page it makes sense to us, but to others it is impossible to find what sections need to be changed when a bug is found. Even worse, if the bug exists in the copied code it needs to be fixed in the source and all copied locations. This is a nightmare when it comes to long term maintenance of a site. A component reduces redundant code and simplifies pages into small, easy to understand chunks that can be modified easily. Transitioning to components is somewhat easy but takes some practice to see when something should be broken into a new component. Generally, components should be dumb and not contain too much data interaction. They should take in data to display and execute functions on the parent to mutate data. ...