Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

104
Views
Creación de un archivo que importa y exporta componentes de inmediato nuevamente

No estoy seguro de por qué esto no funciona. solía tener

 // file 1 import Box from '@/components/Box' import Popup from '@/components/Popup' const MDXComponents = { Box, Popup } // using MDXComponents somewhere in file 1

Ahora quiero subcontratar el objeto MDXComponents, ya que se está volviendo demasiado grande. Así que creé un nuevo archivo:

 // file 2 import Box from '@/components/Box' import Popup from '@/components/Popup' export default { Box, Popup }

Y luego de vuelta en el archivo 1 hago:

 // file 1 import * as MDXComponents from './file2' // using MDXComponents somewhere in file 1

No me deja hacer esto, pero no estoy seguro de por qué.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Cuando haces esto:

 export default { Box, Popup };

Establece la exportación predeterminada a un nuevo objeto que tiene 2 propiedades. Necesitarías importar así:

 import MDXComponents from './file2'; // And then destructure the object like any normal object. // You can't do import {} in this case, you get the full object. const { Box } = MDXComponents;

Cuando haces esto:

 export { Box, Popup };

Crea dos exportaciones con nombre que puede importar así:

 // import all named exports import * as MDXComponents from './file2'; // or just one individually import { Box } from './file2';

Para este caso de uso también hay un atajo :

 export { default as Box } from '@/components/Box'; export { default as Popup } from '@/components/Popup'; // If a module has named exports (not just a default export) // and you want to export them all: export * from 'some-module'; // Or just some: export { someOtherThing } from '@/components/Box'; export { default as Popup, someOtherThing } from '@/components/Popup';
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!