You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Sidebar.js/** * Sidebar for shipping information details */import{Sidebar}from'@coreui/coreui';importReact,{Component,useEffect,useState}from'react';import{httpHelper}from"./helpers/httpHelper"exportdefaultSidebar=()=>{// const productsconstProducts=()=>{const[product,setProducts]=useState(null)// url to pass values from the json format.consturl="http://localhost:3000/product"constapi=httpHelper()// fetching data as jsonuseEffect(()=>{getProducts()},[])constpostProducts=product=>{api.post('${url}',{body:product}).then(response=>getProducts()).catch(err=>console.log(err))}// get all products information here.constgetProducts=()=>{api.get('${url}?_expand=shipping').then(response=>{getProducts(response)}).catch(err=>console.log(err))}// our products returns when nothing on json if empty.if(!product)returnnull}}
The text was updated successfully, but these errors were encountered:
The main problem here is you're assigning things to names imported from other package. i.e.
import{A}from'a'A=1
Which is not allowed in ESM context (where you can treat the A as if it was defined by const A = ..., assigning to a constant value is not allowed), and is not safe to use it in CJS conext.
When you transform this code to CJS, it becomes:
varimport_a=require("a");import_a.A=1;
It is not SAFE when the package a export things like:
There's the issue of it crashing when run due to how JavaScript imports work (which has nothing to do with esbuild). But it also just looks wrong because even if it didn't crash, why would you want to overwrite an import like this? Are you perhaps confused about how to export something in JavaScript?
Did you mean to use a default export like this instead?
exportdefault()=>{
Or did you mean to export the name Sidebar instead of default?
exportletSidebar=()=>{
You can also export the same thing as both Sidebar and default if you want to:
export{Sidebarasdefault}exportletSidebar=()=>{
In any case, esbuild already points this out for you. This is an error when bundling:
✘ [ERROR] Cannot assign to import "Sidebar"
example.js:10:15:
10 │ export default Sidebar =() => {
╵ ~~~~~~~
Imports are immutable in JavaScript. To modify the value of this import, you must export a setter
function in the imported file (e.g. "setSidebar") and then import and call that function here
instead.
I guess this means it should also be a warning when not bundling.
Hi team
i am getting this issue on Sidebar.js
The text was updated successfully, but these errors were encountered: