I'm using react typescript and simply want to create a select component for a time zone picker. I tried using npm library react-timezone-select. But it is giving the below errors in the console:
index.js:1 ./node_modules/react-timezone-select/dist/esm/index.js 9693:38
Module parse failed: Unexpected token (9693:38)
File was processed with these loaders:
./node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
r = ts(a[0]); let o = "", s = n.isDST() ? r[0].daylight?.abbr : r[0].standard?.abbr, l = n.isDST() ? r[0].daylight?.name : r[0].standard?.name; const u = 60 * t.current.offset, I can't figure out what am I doing wrong. Can't use npm libraries in react typescript?
I tried installing react-timezone-select using the below commands
npm i react-timezone-select npm i @types/react-timezone-select Also, I changed the tsconfig.json file to include
"lib": ["DOM", "ES6", "DOM.Iterable", "ScriptHost", "ES2016.Array.Include", "esnext"], "include": ["src", "backend", "src/**/*.ts", "src/**/*.tsx"] but none of it worked and the same error is persistent.
I expected typescript to make life easier but instead, it creates more problems with every other npm library.
1 Answer
It seems updating the react-scripts to 5.0.1 fixes your problem. Refer to this thread