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

228
Views
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 answers
Answer question

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 Report

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 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!