I configured my simple webapp to build and run a WDS with TypeScript + React. It builds and shows the page properly.
Then, I am trying to add Redux and when I do a simple thing like importing useDispatch and trying to call it from my functional component, it builds but shows the error in browser console:
Uncaught SyntaxError: Unexpected token ':'
The code is:
import { useDispatch } from 'react-redux'
const MyView = () =>{
const dispatch = useDispatch()
...
}
And the page shows nothing.
When I look into the source of the error, I see it's definitely not good because tries to access {...}.somValue which should be something like ({...}).somValue to not cause the error.

Is it something I can fix by changing webpack config? I only use ts-loader, without any babel stuff.
Seems like I had a wrong value in webpack config file, or at least removing it helped:
Was mode: "none"
I just removed the whole key and value and it worked.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With