DEV Community

loizenai
loizenai

Posted on

React Stateless Functional Components example

https://grokonez.com/frontend/react/react-stateless-functional-components-example

React Stateless Functional Components example

We have known how to define a React Component in the post React Components example. There is a simpler way to do this which is called stateless functional components. Remember that we can only use this method for components that don't have state.

Related Posts:

I. How to

With component that we created from the class:

class MyComponent extends React.Component {
    render() {
        return (
            <div>
                <h2>{this.props.abc}</h2>
                <h4>{this.props.xyz}</h4>
            </div>
        );
    }
}

We can define it in another way (stateless functional component way):

const Header = (props) => {
    return (
        <div>
            <h2>{props.abc}</h2>
            <h4>{props.xyz}</h4>
        </div>
    );
};

We can see that the stateless component is just a function. There is no this keyword.

II. Practice

1. Overview

We will build a React Note Application like the post: React Note Application – React props and state example using Stateless Functional Components wherever we can:

react-note-app-goal

More at:
https://grokonez.com/frontend/react/react-stateless-functional-components-example

React Stateless Functional Components example

Top comments (0)

Jetbrains image

Build Secure, Ship Fast

Discover best practices to secure CI/CD without slowing down your pipeline.

Read more

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay