Skip to content
Advertisement

Tag: es6-modules

Component in vanilla Javascript?

I have tried to create to create a component in vanilla JavaScript here in main js file I am trying to call a function that is defined in a component and also I am expecting an output but it gives me error saying showMovies is not a function. Can anyone tell me what is right way to do so: Answer

es6 modules: import specific-functions as aName

I’d like to import specific functions from another module. But I faced naming collision: I have similar function names in my importing file. I’d like to do something like this: I know I could import * as exporter from “exporterFile.js” but it lacks readability and does not show what methods (functions) I am using from the exporter file. Also, I

Spreading es6 import statements where they are used

In a js file that has no top-level code running, (it just exports functions), should every import statement be placed at the top of the file? Or can I spread them where they make more syntactic sense to me? Does this affect performance and would you consider such code “hard to read”? Example (all on top): Example (spread, so that

how to fix unexpected token parsing error?

The arrow works for me all time but i get an error now Parsing error: Unexpected token => I tried checking the syntax and bracket and yeah, I dint miss any brackets. Code : Error : Parsing error: Unexpected token => And If try to change it to normal function(){} call, like this It gives me Parsing error:unexpected token function

“Cannot use import statement outside a module” error when importing react-hook-mousetrap in Next.js

Trying out Next.js but I’m struggling with the following. Just tried to install react-hook-mousetrap and imported it like I normally would: This gives me the following error: I am not sure what this means? I then thought it might be a problem with Nextjs’s SSR, since my library enables hotkeys and will use some browser APIs. If you already know

Advertisement