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
🌐
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%
Discussions

reactjs - How to use a utility class instance in react different components and prevent reinitialization and only one instance is used on all components - Stack Overflow
I have a class in a separate file and two or more different react components that need to use the class methods One approach was I initially created an instance of the class outside the react compo... More on stackoverflow.com
🌐 stackoverflow.com
React.js : reusable components vs mixin's utility functions
From clean code point of view, I would either write a component or use a non-react utility function that just formats the date to a string - no need to couple the date formatting and dom elements. More on stackoverflow.com
🌐 stackoverflow.com
Which is the best React component library?
I started building my own component library about a year ago. You can check it out here if you want: https://rewind-ui.dev/ It's built on top of TailwindCSS and CVA. I have implemented some components that you might not find on other component libraries like the Sidebar: https://rewind-ui.dev/components/sidebar Other than that I believe that the most complete library out there is Mantine, but I haven't used it with TailwindCSS yet. More on reddit.com
🌐 r/react
64
92
January 31, 2024
Is it a good idea to mix component and utility classes?

Personally I’m a big fan of using the styled components approach , that way you separate out layout or “utility” classes and logic from your main component logic , also makes for super easy reuse

More on reddit.com
🌐 r/react
2
1
November 12, 2021
🌐
Untitled UI
untitledui.com › react › components
Open-source React UI components | Untitled UI
Dashboard, settings, form layouts—useful examples for everything you need to design modern dashboards and responsive web applications. ... Landing page headers and website sections—everything you need to design modern and responsive marketing ...
🌐
DEV Community
dev.to › mahmoudelmahdi › react-utility-components-eak
React Utility Components - DEV Community
December 5, 2022 - import { If } from "@melmahdi/reactuc"; <If condition={condition: 1 | 0} otherwise={otherwise: ReactNode}> ... </If> ... Component to handle iterations.
🌐
GitHub
github.com › brillout › awesome-react-components
GitHub - brillout/awesome-react-components: Curated List of React Components & Libraries. · GitHub
react-refetch - A simple, declarative, and composable way to fetch data for React components. redux-connect - Provides decorator for resolving async props in react-router. ... query - docs Powerful asynchronous state management, server-state ...
Starred by 47.2K users
Forked by 3.8K users
🌐
React
legacy.reactjs.org › docs › components-and-props.html
Components and Props – React
This lets us use the same component abstraction for any level of detail. A button, a form, a dialog, a screen: in React apps, all those are commonly expressed as components. For example, we can create an App component that renders Welcome many times:
🌐
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 ·
🌐
GitConnected
levelup.gitconnected.com › react-utility-components-building-4-react-components-that-improve-any-app-2fa0e4672e0f
React Utility Components: Building 4 React Components that Improve Any App | by Mahmoud Elmahdi | Level Up Coding
November 25, 2019 - For example, this could be list of strings or a list of objects. const data = ['...', '...', '...'];<For of={data} type='p' />const anotherData = [ { label: '...', value: '...', } { label: '...', value: '...', } { label: '...', value: '...', ...
Find elsewhere
🌐
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. Here’s a breakdown of their benefits and common use cases: DRY (Don’t Repeat Yourself): By encapsulating common logic, you avoid duplicating code across components.
🌐
Pluralsight
pluralsight.com › blog › guides
Importing Utility Functions in React.js | Online Courses, Learning Paths, and Certifications - Pluralsight
Since the functions will be exported as modules, you need to prepend it with the export keyword. utils.js will look like this: export function computeDollars(btc, btcRate) { return btc * btcRate; } export function formatDollars(dollars) { dollars = (Math.round(dollars * 100) / 100).toFixed(2); dollars = dollars.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); return dollars; } Over at your BTCDollarConverter component, add the following at the top part of the file (after import React from 'react') to import the two functions:
🌐
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.
🌐
Medium
samithahewawasam-27681.medium.com › empowering-react-development-essential-utility-functions-0766aef65271
Empowering React Development: Essential Utility Functions | by Samithahewawasam | Medium
May 10, 2024 - import React from 'react'; function ParentComponent({ children }) { return ( <div> {React.Children.map(children, (child, index) => ( // Manipulate or clone child components React.cloneElement(child, { key: index }) ))} </div> ); } ... Converts ...
🌐
GitHub
github.com › react-component › util
GitHub - react-component/util: Common Utils For React Component
import warning, { noteOnce } from 'rc-util/lib/warning'; warning(false, '[antd Component] test hello world'); // Low level note noteOnce(false, '[antd Component] test hello world'); A collection of functions to operate React elements' children.
Starred by 663 users
Forked by 193 users
Languages   TypeScript 99.9% | TypeScript 99.9%
🌐
Builder.io
builder.io › blog › react-component-libraries-2026
15 Best React UI Libraries for 2026
December 16, 2025 - Tailwind CSS changed how developers think about styling with its utility-first approach. These libraries work with Tailwind, giving you component logic while preserving the utility class workflow you're used to.
🌐
Prismic
prismic.io › blog › react-component-libraries
Best 19 React UI Component Libraries in 2026
August 19, 2024 - Designs for popular frameworks: Components come with React, Vue, and AlpineJS code examples, so you can easily integrate them. Customizable: All components are customizable with Tailwind CSS utility classes.
🌐
W3Schools
w3schools.com › react › react_components.asp
React Components
React ES6 ES6 Classes ES6 Arrow Functions ES6 Variables ES6 Array map() ES6 Destructuring ES6 Spread Operator ES6 Modules ES6 Ternary Operator ES6 Template Strings React JSX Intro React JSX Expressions React JSX Attributes React JSX If Statements React Components React Class React Props React Props Destructuring React Props Children React Events React Conditionals React Lists React Forms React Forms Submit React Textarea React Select React Multiple Inputs React Checkbox React Radio React Portals React Suspense React CSS Styling React CSS Modules React CSS-in-JS React Router React Transitions React Forward Ref React HOC React Sass
🌐
React
react.dev › reference › react › Component
Component – React
Typically, it is used together with static getDerivedStateFromError which lets you update state in response to an error and display an error message to the user. A component with these methods is called an Error Boundary. See an example.
🌐
MUI
mui.com › material-ui
Material UI: React components that implement Material Design
Ready-to-use foundational React components, free forever. ... Advanced and powerful components for complex use cases. ... Fully built templates for your application. ... Material UI components in your favorite design tool. ... Component library that implements Google's Material Design. ... Component library that implements MUI's own in-house design principles. ... Unstyled components for building accessible UIs. ... CSS utilities for rapidly laying out custom designs.