why do we import with curly brackets in react code example
Example 1: what are the used of curly brackets in react functions
const destructuring = ({ used }) => console.log(used);
const properties = {
unused: 1,
used: 2,
};
destructuring(properties); // 2
Example 2: react import brackets
// When importing use no brackets for the corresponding default
// export, but include brackets for the corresponding named exports.
// A module can only have one default export, but several named exports.
// X.js
export const myX = 10 // named export
export const Hey = 20 // named export
export default 30 // default export
// Y.js
import { myX } from './X' // named import, name 'myX' must match X.js
import { Hey as whatever } from './X' // named import, changing the name
import wow from './X' // default import, name 'wow' could be anything
import * as whatever // named import of object with all named exports in X.js