top of page
Logo der Online Agentur mdwp


"Class" is a concept in React and in JavaScript in general that is used to create components. A class in React JS is a blueprint for creating objects which encapsulate data and functionalities that belong together.

A React component defined as a class has some additional features not available in components defined as functions. Class components have some additional features such as lifecycle methods and the ability to store internal state.

Here's a simple example of a React class component:

class Welcome extends React.Component {
render() {
return <h1>Hello, {}</h1>;
In the code above, the `Welcome` class extends `React.Component` indicating that it's a React component. The `render` method within the class is used to define what the UI of the component looks like. This class accepts 'props' (short for properties), which are values or functions passed into a component from its parent component. In this case, it's expecting a 'props' value named 'name' which it will display within a header tag.

This isn't possible in functional components which makes class components special as they provide more capabilities. However, with the introduction of hooks in React 16.8, many of these features became available to functional components as well.

bottom of page