Skip to main content

Create a React.js Component

Select a "good" component name

When you add a component to the project, you should really think how you are going to name it.

Questions you should ask yourself before naming the component:

  • Is the name meaningful? Does the name state what the component does?
  • Is the name written in camelcase?
  • Does the component name describe what the component does?

Write the code for your first Component

Readability

When you create a new component, the code should be as readable as possible.

Why is that?

  • You will probably have to edit the file later on. You should be able to understand wha it does. you maybe understand the code now, but after a month you will probably do not.

  • You are not alone in this project. You will have to make sure that even the most stupid person on the planet can understand what the code does. (Yes, even a 5-year-old)

  • The code you will write now, will be the base of how this entire project will continue. Explain it as much as possible. Do not take anything for granted.

Write comments

While many people (particularly students) use comments to delete their code.(Some part of their code is not running, so they comment it out). You are allowed to do that while you are developing the plugin, but you are not allowed to leave these comments when you submit a pull request. These comments may get in the way of other programmers who will read your code.

Instead, you should add comments that describe what your code does, what feature it implements etc.