If you are just starting React JS or looking for a way to start React JS, check out these examples below:
These examples/concepts are a must for a beginner to get well versed with.
Stateful Components are components depending on its state object and change its own state. The component re-renders based on changes to its state, and may pass down properties of it’s state to child components as properties on a props object.
Fig.1 Stateful Components
Stateless Components purely acts as a view, the components do not have any state. Here, we pass props (method argument) and provide the value along with it. Notice there is “this” keyword.
Fig.2. Stateless component
Implicit Return Components are the same as above but without a return statement. This would be useful when you are creating a button or a default form that could be used elsewhere.
Fig.3. Implicit React Component
Fragments are used to render multiple elements without using a wrapper class. Fragments let you group a list of children without adding extra nodes to the DOM. Fragments are used in place of necessary
Fig.4. Fragment in React
Normally you would use
JSX allows to write HTML elements in JS and place them in the DOM without any createElement() or appendChild() methods. It is used to convert HTML tags into react elements.
Fig.5. JSX element
Only single parent tag is allowed which means that no multiple parent tags are allowed, either nest it in
- ,