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

231
Vistas
How can I use React style imports for my own files?

I would like to use this form often used in React or in this example react-redux

import redux, { useSelector, useDispatch } from 'react-redux';

So I tried the obvious:

I created an export file:

const exp = {};
exp.a = 'a-1';
exp.b = 'b-1'; 
export default exp;

And a file to import it:

import {a, b} from './40-export.js';  // this does not work
// import test from './40-export.js';  // this works
// const {a, b} = test;  // this works
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You need to both have an export default and named exports. Make standalone a and b variables that you export, and that you assign to properties of the default export object.

export const a = 'a-1';
export const b = 'b-1'; 
export const exp = { a, b }; // if you want this to be a named export too
export default exp;
about 4 years ago · Juan Pablo Isaza Denunciar

0

export const a = 2
export const b = 3
export default const c = 3

Then

import c , {a, b} from "your/file"

Note the use of {...} for named imports and the lack of it for default exports.

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