Hey! You are exporting both a component and a function from the same file. Fast Refresh only works, when you're exporting components exclusively. For Fast Refresh to work, you need to put your NotePage Component and the loader into different files, e.g., notepage.element.tsx and notepage.loader.ts.

🌐
npm
npmjs.com › package › eslint-plugin-react-refresh
eslint-plugin-react-refresh - npm
The plugin relies on naming conventions (i.e. use PascalCase for components, camelCase for util functions). This is why there are some limitations: export * are not supported and will be reported as an error · Anonymous function are not supported (i.e export default function() {}) ... All-uppercase function export is considered an error when not using direct named export (ex const CMS = () => <></>; export { CMS }) ... This plugin provides a single rule, react-refresh/only-export-components.
      » npm install eslint-plugin-react-refresh
    
Published   Feb 23, 2026
Version   0.5.2
Author   Arnaud Barré
🌐
GitHub
github.com › ArnaudBarre › eslint-plugin-react-refresh
GitHub - ArnaudBarre/eslint-plugin-react-refresh: Validate that your components can safely be updated with Fast Refresh · GitHub
import { defineConfig } from "eslint/config"; import { reactRefresh } from "eslint-plugin-react-refresh"; export default defineConfig({ // in main config for TSX/JSX source files plugins: { "react-refresh": reactRefresh.plugin, }, rules: { "react-refresh/only-export-components": "error", }, });
Starred by 329 users
Forked by 23 users
Languages   TypeScript 95.3% | JavaScript 4.7%
🌐
Reddit
reddit.com › r/react › how is this done in real life work? react context warning "fast refresh only works..."
r/react on Reddit: How is this done in real life work? React Context warning "Fast refresh only works..."
April 19, 2025 -

SOLVED: I ended up making a context.jsx and a provider.jsx, which seems kinda weird to me, but what do i know im just a jr.

Hello! I'm trying to learn to use contexts but i get this warning "Fast refresh only works when a file only exports components. Move your component(s) to a separate file."

I get it, its because im exporting twice. But how should i do it correctly? 2 files? One for context and one for provider??

This is my context.jsx, then i have a Cart.jsx where i plan to use it, and a Layout.jsx that wraps the outlet with the context

import {useState, createContext } from "react";

export const CartContext = createContext()

export function CartProvider({children}){
    const [cart, setCart] = useState([])

    const handleCart = (new) =>{
        setCart((prevCart) => [...prevCart, new])
    }

    return(
        <CartContext.Provider value={{cart, handleCart }}>
            {children}
        </CartContext.Provider>
    )
}
🌐
Biome
biomejs.dev › linter › rules › use-component-export-only-modules
useComponentExportOnlyModules | Biome
The default severity of this rule is warning. ... Enforce declaring components only within modules that export React Components exclusively. This is necessary to enable the React Fast Refresh feature, which improves development efficiency.
🌐
GitHub
github.com › yannickcr › eslint-plugin-react › issues › 3176
new rule: forbid exporting React Components and non-components ...
January 12, 2022 - According to the official react-fast-refresh docs: If you edit a module that only exports React component(s), Fast Refresh will update the code only for that module, and re-render your component. You can edit anything in that file, inclu...
Author   Alloyed
Find elsewhere
🌐
Medium
leapcell.medium.com › beyond-hmr-understanding-reacts-fast-refresh-d6d80ef0fe4e
Beyond HMR: Understanding React’s Fast Refresh | by Leapcell | Medium
February 18, 2025 - If you edit a module file that only exports React components, Fast Refresh will only update the module’s code and re-render your components.
🌐
Gatsby
gatsbyjs.com › documentation › reference guides
Fast Refresh | Gatsby
The file you’re editing might have other exports in addition to a React component. Gatsby includes an ESLint rule by default to warn against this pattern in pages: Page templates must only export one default export (the page) and query as a named export.
🌐
GitHub
github.com › shadcn-ui › ui › issues › 1534
Export pattern causes warning from `eslint-plugin-react-refresh` · Issue #1534 · shadcn-ui/ui
September 16, 2023 - After initializing in a new React Vite TS Storybook starter, that happened to have this eslint plugin installed, I get warnings on a number of files that export functions in addition to a component. Also, although documentation about "Fast Refresh" is a bit scant unfortunately, some resources on it also say that each export requires its own export statement... https://github.com/ArnaudBarre/eslint-plugin-react-refresh ... { plugins: ['react-refresh'], rules: { 'react-refresh/only-export-components': [ 'warn', { allowConstantExport: true }, ], }, }
Author   lunelson
🌐
Reddit
reddit.com › r/react › "tricking" hmr in react-refresh to treat an export similarly to component exports
r/react on Reddit: "Tricking" HMR in react-refresh to treat an export similarly to component exports
December 6, 2023 -

Hi there.

We are facing an interesting challenge with HMR in react-refresh that I would love to hear if someone has solved elegantly before.

Context

We are building an extensible admin dashboard in React using Vite (currently migrating from webpack). The dashboard comes with dedicated "injection zones" where developers can create and inject their own components to support their specific use case.

(I can provide more context if needed)

An extension looks like this:

import type { WidgetConfig } from "@medusajs/admin"

const ProductWidget = () => {
  return (
    <div>
      <h1>Product Widget</h1>
    </div>
  )
}

export const config: WidgetConfig = {
  zone: "product.details.after",
}

export default ProductWidget

The component, here ProductWidget, is what gets injected. The config is what defines where it is injected. Both are used at build time to extend the default admin application.

As you can see, this breaks HMR because the files do not only export React components. This means everytime an update is made to this component, the entire component will be re-run, as well as other files that might import it. This is less than ideal. Please note, I understand why HMR works like this, so let's not get too much into that.

We would reeeeeally like to keep the current developer experience of creating extensions i.e. having files that export a component + a specific config object, but I fear we need to bite the bullet and change the way our config is exported.

We've found that `tanstack/router` was patched to make HMR work as expected, but this solution doesn't work for us, as our config is not a class: https://github.com/TanStack/router/commit/9f2150190a628fb3767ca8ad0d8634b357f43c51

Has anyone managed to solve this elegantly? Does anyone have ideas for how we could solve this elegantly?

🌐
Socket
socket.dev › npm › package › eslint-plugin-react-refresh
eslint-plugin-react-refresh - npm Package Security Analysis ...
import { defineConfig } from "eslint/config"; import reactRefresh from "eslint-plugin-react-refresh"; export default defineConfig({ // in main config for TSX/JSX source files plugins: { "react-refresh": reactRefresh, }, rules: { "react-refresh/only-export-components": "error", }, });
🌐
Lightrun
lightrun.com › answers › jsx-eslint-eslint-plugin-react-new-rule-forbid-exporting-react-components-and-non-components-from-the-same-module
new rule: forbid exporting React Components and non-components from the same module
According to the official react-fast-refresh docs: * If you edit a module that only exports React component(s), Fast Refresh will update the code only for ...
🌐
Reddit
reddit.com › r/nextjs › how to diagnose "fast refresh had to perform a full reload"?
r/nextjs on Reddit: How to Diagnose "Fast Refresh had to perform a full reload"?
July 7, 2023 -

I've been getting "Fast Refresh had to perform a full reload. See https://nextjs.org/docs/basic-features/fast-refresh#how-it-works" warnings in my dev logs and it'd be nice to not.

I'm going to guess the culprit is exporting the props types along with the component. However, I'm guilty of doing this a lot and refactoring would be a pain unless I know it is in fact the issue.

Is there a good way to determine the actual cause? a lint rule? a verbose log?

🌐
React Router
reactrouter.com › explanation › hot-module-replacement
Hot Module Replacement | React Router
That's exactly what React Fast Refresh is all about! Of course, React is all about components, not general JavaScript code, so React Fast Refresh only handles hot updates for exported React components.
🌐
Stack Overflow
stackoverflow.com › questions › tagged › react-refresh
Newest 'react-refresh' Questions - Stack Overflow
Say I have a module foo and it's got some stuff in it: // foo/index.js export { default as SomeComponent } from './SomeComponent' export { someUtil } from './utilities' export const SOME_CONSTANT = 42 ... ... I got the below error when deploying the code in cloud in local (windows) its working normally. When deploying in cloud I am getting following error: ** Uncaught Error: Cannot find module '/React/... ... I'm building a React app and I keep getting the same errors that I just can't fix: Module not found: Error: You attempted to import server/reactweb/node_modules/react-refresh/runtime.js which falls ...