Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

142
Vistas
React.js component doesn't work in Next.js builds

I'm trying to build a React accordion component as an NPM package named Accordie.

It's working on Next.js development but not in production.

Here's a CodeSandbox demo for development mode and here's a Vercel demo for production mode.

Looks like this on CodeSandbox.

enter image description here

And looks like this on Vercel.

enter image description here

There's a flashing issue on production build. I have no idea about what to do. Probably something wrong with the build script.

I'm using Babel to transpile JSX files like this.

"build": "rm -rf build && NODE_ENV=production babel src --out-dir build --copy-files",

And I need a general help about how to build a React component to be able to make it work in Next.js builds.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I figured it has nothing to do with the build scripts.

I was using something like this. Exporting <Panel> and returning <Panel> inside the map.

const Panel = ({}) => {
  return (
    ...
  )
}

const Accordie = ({ children }) => {
  return (
    <>
      {children.map((child, key) => {
        if (child.type.name !== 'Panel') return null

        return (
          <Panel
            ...
          />
        )
      })}
    </>
  )
}

module.exports = {
  Panel,
  Accordie
}

Now just exporting an empty <Panel> and using <PanelInner> instead.

const Panel = () => null

const PanelInner = ({}) => {
  return (
    ...
  )
}

const Accordie = ({ children }) => {
  return (
    <>
      {children.map((child, key) => {
        if (child.type.name !== 'Panel') return null

        return (
          <PanelInner
            ...
          />
        )
      })}
    </>
  )
}

module.exports = {
  Panel,
  Accordie
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda