๐ŸŒ
React
legacy.reactjs.org โ€บ docs โ€บ components-and-props.html
Components and Props โ€“ React
However, if you integrate React into an existing app, you might start bottom-up with a small component like Button and gradually work your way to the top of the view hierarchy. Donโ€™t be afraid to split components into smaller components. ... function Comment(props) { return ( <div className="Comment"> <div className="UserInfo"> <img className="Avatar" src={props.author.avatarUrl} alt={props.author.name} /> <div className="UserInfo-name"> {props.author.name} </div> </div> <div className="Comment-text"> {props.text} </div> <div className="Comment-date"> {formatDate(props.date)} </div> </div> ); }
๐ŸŒ
W3Schools
w3schools.com โ€บ react โ€บ react_components.asp
React Components
Components come in two types, Class components and Function components, in this tutorial we will concentrate on Function components. In older React code bases, you may find Class components primarily used.
People also ask

What are functional components in React?
Functional components are JavaScript functions that return React elements. They are simpler, easier to test, and perform better than class components.
๐ŸŒ
knowledgehut.com
knowledgehut.com โ€บ home โ€บ blog โ€บ software development โ€บ react functional components with examples [in-depth guide]
React Functional Components: In-Depth and Detailed Guide | upGrad blog
What are the functional components of React?
Functional components in React are stateless or stateful functions that return JSX and rely on hooks like useState and useEffect for managing state and side effects.
๐ŸŒ
knowledgehut.com
knowledgehut.com โ€บ home โ€บ blog โ€บ software development โ€บ react functional components with examples [in-depth guide]
React Functional Components: In-Depth and Detailed Guide | upGrad blog
Which component is better in React?
Functional components are generally considered better due to their simplicity, performance benefits, and hook support, making them the standard choice in modern React development.
๐ŸŒ
knowledgehut.com
knowledgehut.com โ€บ home โ€บ blog โ€บ software development โ€บ react functional components with examples [in-depth guide]
React Functional Components: In-Depth and Detailed Guide | upGrad blog
๐ŸŒ
Robin Wieruch
robinwieruch.de โ€บ react-function-component
React Function Components - Robin Wieruch
December 23, 2024 - The function executes delayed without any further instructions from your side within the component. The component will also rerender asynchronously in case props or state have changed. Take the following code as example to see how we set state with a artificial delay by using setTimeout: ... import React, { useState } from 'react'; const App = () => { const [count, setCount] = useState(0); const handleIncrement = () => setTimeout( () => setCount(currentCount => currentCount + 1), 1000 ); const handleDecrement = () => setTimeout( () => setCount(currentCount => currentCount - 1), 1000 ); return ( <div> <h1>{count}</h1> <Button handleClick={handleIncrement}>Increment</Button> <Button handleClick={handleDecrement}>Decrement</Button> </div> ); }; const Button = ({ handleClick, children }) => ( <button type="button" onClick={handleClick}> {children} </button> ); export default App;
๐ŸŒ
React Native
reactnative.dev โ€บ docs โ€บ intro-react
React Fundamentals ยท React Native
February 20, 2026 - The following example takes place in a cat cafe where two hungry cats are waiting to be fed. Their hunger, which we expect to change over time (unlike their names), is stored as state.
๐ŸŒ
React
react.dev โ€บ learn โ€บ your-first-component
Your First Component โ€“ React
With function Profile() { } you define a JavaScript function with the name Profile. React components are regular JavaScript functions, but their names must start with a capital letter or they wonโ€™t work!
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ reactjs-functional-components
ReactJS Functional Components | GeeksforGeeks
In this article, we will see some ... first example of GeeksforGeeks's homepage whi ... ReactJS Pure Components are similar to regular class components but with a key optimization. They skip re-renders when the props and state remain the same. While class components are still supported in React, it's generally recommended to use functional components ...
Published ย  February 17, 2025
๐ŸŒ
React
react.dev โ€บ learn โ€บ keeping-components-pure
Keeping Components Pure โ€“ React
In the above example, double is a pure function. If you pass it 3, it will return 6. Always. React is designed around this concept. React assumes that every component you write is a pure function.
๐ŸŒ
React TypeScript Cheatsheets
react-typescript-cheatsheet.netlify.app โ€บ function components
Function Components | React TypeScript Cheatsheets
React.FunctionComponent is explicit about the return type, while the normal function version is implicit (or else needs additional annotation).
Find elsewhere
๐ŸŒ
InfoWorld
infoworld.com โ€บ home โ€บ software development โ€บ programming languages โ€บ javascript
How to use React functional components | InfoWorld
January 14, 2021 - The functional version, instead of calling ReactDOM.render(), simply returns a value, which is also JSX.
๐ŸŒ
KnowledgeHut
knowledgehut.com โ€บ home โ€บ blog โ€บ software development โ€บ react functional components with examples [in-depth guide]
React Functional Components: In-Depth and Detailed Guide | upGrad blog
April 15, 2025 - ... import React from 'react'; const Dashboard = () => { return <h1>This is dashboard component</h1>; }; export default Dashboard; Below is the example for importing the component using the import keyword -
๐ŸŒ
React
legacy.reactjs.org โ€บ docs โ€บ faq-functions.html
Passing Functions to Components โ€“ React
Throttling prevents a function from being called more than once in a given window of time. The example below throttles a โ€œclickโ€ handler to prevent calling it more than once per second. import throttle from 'lodash.throttle'; class LoadMoreButton extends React.Component { constructor(props) { super(props); this.handleClick = this.handleClick.bind(this); this.handleClickThrottled = throttle(this.handleClick, 1000); } componentWillUnmount() { this.handleClickThrottled.cancel(); } render() { return <button onClick={this.handleClickThrottled}>Load More</button>; } handleClick() { this.props.loadMore(); } }
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ react-components-jsx-props-for-beginners
React Functional Components, Props, and JSX โ€“ React.js Tutorial for Beginners
November 5, 2020 - After getting used to the JSX syntax, the next thing to understand is the component-based structure of React. If you revisit the example code at the top of this post, you'll see that the JSX code is being returned by a function. But the App( ) function is not an ordinary function โ€“ it is actually a component.
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ function-component-vs-class-component-in-react
Function Components vs Class Components in React โ€“ With Examples
April 16, 2024 - The first example uses the function keyword to define the function component, while the second example uses arrow function syntax. Both syntaxes are valid and achieve the same result. State Management: Traditionally, function components were stateless and couldn't hold their own state. However, with the introduction of React Hooks (like useState), function components can now manage state using Hooks.
๐ŸŒ
Pragimtech
pragimtech.com โ€บ blog โ€บ reactjs โ€บ Introduction-to-Function-Components-React
What are Function Components in React
Lets modify the same code using Arrow function. const Employee=(data)=> { return <div><p>Name : {data.name}</p> <p>Salary : {data.salary}</p></div>; } Note: Always start component names with a capital letter.
๐ŸŒ
W3Schools
w3schools.com โ€บ react โ€บ react_es6_arrow.asp
React ES6 Arrow Functions
React Compiler React Quiz React Exercises React Syllabus React Study Plan React Server React Interview Prep React Bootcamp React Certificate ... It gets shorter! If the function has only one statement, and the statement returns a value, you can remove the brackets and the return keyword:
Top answer
1 of 6
22

Are these interchangeable?

Short answer: No.


Let's take a look at the different snippets you've posted:


someFunction() vs someFunction

With the former syntax, you are actually invoking that function. The latter is just a reference to that function. So when do we use which?

  • You would use someFunction() when you want that function invoked and its result returned immediately. In React, this is typically seen when you split parts of your JSX code to a separate function; either for reasons of readability or reusability. For example:

    render() {
      myFunction() {
        return <p>Foo Bar</p>;
      }
      return (
        <div>
          {myFunction()}
        </div>
      );
    }
    

  • You would use someFunction when you want only to pass the reference to that function to something else. In React, this is usually an event handler that is passed down to another child-component via props so that that component can call the event handler when it needs to. For example:

    class myApp extends React.Component {
      doSomething() {
        console.log("button clicked!");
      }
      render() {
        return (
          <div>
            <Button someFunction={this.doSomething} />
          </div>
        );
      }
    }
    
    class Button extends React.Component {
      render() {
        return (
          <button onClick={this.props.someFunction}>Click me</button>
        );
      }
    }
    

someFunction() vs this.someFunction()

This has to do with the context of the function. Basically, "where is this function?". Is part of the current Component, then use this.someFunction(), is it part of the parent Component passed in as props, then use this.props.someFunction(). Is it a function inside the current method, then just use someFunction().

Obviously, there's a lot more to it than that, but it's the best basic summary I can give.

For a better understanding, have a read here. It is a great guide to how the this keyword works in Javascript and in React in particular.

2 of 6
4

If you want to call a function options 2 and with some assumptions 5 should work.

If you want to actually pass a function as a property to some child component so that it could call it later (say to notify your root element on some event) then option 1 (with prebind) and 3 (with defining a variable const {handleAddTodo} = this and prebind :) ) should work

// this works if handleAddTodo was prebinded or doesn't use this
handleAddTodo ={this.handleAddTodo} 

// this probably wont work unless handleAddTodo is higher order function that returns another function
handleAddTodo ={this.handleAddTodo()} 

// This wont work unless you have a var/let/const that is referencing a function
handleAddTodo ={handleAddTodo} 

// Same as 1
handleAddTodo ={this.handleAddTodo} 

// 3 and 2 combined
handleAddTodo ={handleAddTodo()} 
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ a-few-questions-on-functional-components
How to Use Functional Components in React
May 3, 2020 - Passing an update function allows you to access the current state value inside the updater. OK so increment() gets called with the current n state and it is used to compute the new state value. Letโ€™s summarize what we found out. In React we can simply define a component using a function that ...
๐ŸŒ
Groove Technology
groovetechnology.com โ€บ home โ€บ blog โ€บ technologies โ€บ reactjs functional components: everything you need to know
ReactJS Functional Components: A Complete Overview
September 26, 2024 - Creating a functional component in ReactJS is simple. All you need to do is define a function that returns JSX (JavaScript XML) code. Hereโ€™s an example of a basic ReactJS functional component:
๐ŸŒ
Educative
educative.io โ€บ answers โ€บ how-to-create-a-function-in-react
How to create a function in React
Line 11: We export the HelloWorld function as the default export, allowing it to be imported into other components. Note: Each file can have only one default export, which allows a single item to be exported and imported without curly braces, while named exports enable multiple items to be exported and imported with curly braces. Understanding the distinction between default and named exports in React is essential for organizing component structure effectively.