Utils.js with latest Javascript ES6 syntax

Create the Utils.js file like this with multiple functions, etc

const someCommonValues = ['common', 'values'];
    
export const doSomethingWithInput = (theInput) => {
   //Do something with the input
   return theInput;
};
    
export const justAnAlert = () => {
   alert('hello');
};

Then in your components that you want to use the util functions, import the specific functions that are needed. You don't have to import everything

import {doSomethingWithInput, justAnAlert} from './path/to/Utils.js'

And then use these functions within the component like this:

justAnAlert();
<p>{doSomethingWithInput('hello')}</p>
Answer from Fangming on Stack Overflow
🌐
DEV Community
dev.to › mahmoudelmahdi › react-utility-components-eak
React Utility Components - DEV Community
December 5, 2022 - Reusable react components to maximize your coding efficiency. Install npm i... Tagged with react, npm, typescript.
🌐
GitHub
github.com › sindresorhus › react-extras
GitHub - sindresorhus/react-extras: Useful components and utilities for working with React
A boolean of whether you're running in a context with a DOM. Can be used to check if your component is running in the browser or if it's being server-rendered. react-router-util - Useful components and utilities for working with React Router
Starred by 730 users
Forked by 29 users
Languages   JavaScript 82.2% | TypeScript 17.8% | JavaScript 82.2% | TypeScript 17.8%
🌐
npm
npmjs.com › package › react-utility-component
react-utility-component - npm
August 22, 2019 - react component utility tools. Latest version: 1.1.6, last published: 5 years ago. Start using react-utility-component in your project by running `npm i react-utility-component`. There are no other projects in the npm registry using react-utility-component.
      » npm install react-utility-component
    
Published   Aug 22, 2019
Version   1.1.6
Author   Naruebaet bouhom
🌐
Made with React.js
madewithreactjs.com › utilities
Utilities - Made with React.js
#Utilities · 393 · Storyblok React Headless CMS with visual editing for React Components · #Utilities #CMS · 4.674 · React Markdown Markdown Component · #Utilities · 2.819 · React Hotkeys Hook Hook for Keyboard Shortcuts · #Utilities · 55 · React Native OTA Hot Update Manage In-App Updates ·
🌐
GitHub
github.com › brillout › awesome-react-components
GitHub - brillout/awesome-react-components: Curated List of React Components & Libraries. · GitHub
dataminr-react-components - Collection of reusable React Components and utility functions.
Starred by 47.2K users
Forked by 3.7K users
Find elsewhere
🌐
Flowbite React
flowbite-react.com
Flowbite React - UI component library
All of the UI components from Flowbite React will automatically invert the colors when activating dark mode via browser settings or using a custom switcher component. ... Flowbite React uses the utility classes from Tailwind CSS under the hood and provides an advanced theming system that you can use to apply classes to UI components and their underlying HTML elements structure.
🌐
Pluralsight
pluralsight.com › blog › guides
Importing Utility Functions in React.js | Online Courses, Learning Paths, and Certifications - Pluralsight
The final form of the component will look like this: import React from 'react'; import { computeDollars, formatDollars } from './utils.js'; export default class BTCDollarConverter extends React.Component { constructor(props) { super(props); this.state = { btc: 0.00, btcRate: 0.00, dollars: 0.00 } } handleBtcChanged(event) { var btc = parseFloat(event.target.value); var dollars = computeDollars(btc, this.state.btcRate); this.setState({ btc: btc, dollars: dollars }); } handleBtcRateChanged(event) { var btcRate = parseFloat(event.target.value); var dollars = computeDollars(this.state.btc, btcRate
🌐
npm
npmjs.com › package › react-utilities
react-utilities - npm
November 25, 2021 - React utility components . Latest version: 0.6.0, last published: 8 years ago. Start using react-utilities in your project by running `npm i react-utilities`. There is 1 other project in the npm registry using react-utilities.
      » npm install react-utilities
    
Published   Jul 19, 2017
Version   0.6.0
Author   zjuasmn
🌐
JavaScript in Plain English
javascript.plainenglish.io › utility-functions-in-react-with-code-examples-7df9e7822092
"React Utility Functions" by Deepak Chaudhari | JavaScript in Plain English
October 17, 2024 - Utility functions are reusable blocks of code that perform specific tasks within a React application. They promote code organization, readability, and maintainability, especially in larger projects.
🌐
Medium
samithahewawasam-27681.medium.com › empowering-react-development-essential-utility-functions-0766aef65271
Empowering React Development: Essential Utility Functions | by Samithahewawasam | Medium
May 10, 2024 - These React.Children methods provide useful utilities for working with the children prop in React components, enabling you to manipulate, iterate over, or validate children components more effectively
🌐
MUI
mui.com
MUI: The React component library you always wanted
MUI provides a simple, customizable, and accessible library of React components. Follow your own design system, or start with Material Design.
🌐
Builder.io
builder.io › blog › react-component-libraries-2026
15 Best React UI Libraries for 2026
December 16, 2025 - A practical guide to the 15 best React UI component libraries for 2026, from full design systems to unstyled and Tailwind-first libraries.
🌐
Kinsta®
kinsta.com › home › resource center › blog › react › react ui components libraries: our top picks
23 React UI Components Libraries: Our Top Picks
December 19, 2025 - You can also create a chart of your own with utilities like tooltip and axis. Interactions: you can use primitives such as brush, zoom, drag, etc., to improve the user experience. Lightweight: you can split visx into several packages and reduce the bundle size. Hence, you can start small, using only the components you need without having to use the entire library.
🌐
Reddit
reddit.com › r/react › where should i put functions that are specific to a component?
r/react on Reddit: Where should I put functions that are specific to a component?
November 2, 2023 -

I noticed I have many components that have functions that are relevant only to them, so I avoided placing these functions in my general services/utilities folders. However sometimes a component of mine will have many functions that are specific to it, and so the file of the component becomes quite long (eg I have a file with 500 lines). I was wondering what is the common way amongst developers of structuring these types of functions or even consts that are related only to a specific component, should I extract them to different files inside the component folder or just leave them in the original file?

🌐
Untitled UI
untitledui.com › react › components
Open-source React UI components | Untitled UI
Explore the world's largest collection of free and open-source React components and website sections. Built with React Aria v1.16 and styled with Tailwind CSS 4.2.
🌐
GitHub
github.com › acdlite › recompose
GitHub - acdlite/recompose: A React utility belt for function components and higher-order components. · GitHub
September 10, 2022 - A React utility belt for function components and higher-order components. - acdlite/recompose
Starred by 15K users
Forked by 1.2K users
Languages   JavaScript 98.9% | HTML 1.1%