Module parse failed
Closed this issue · 3 comments
kykungz commented
@zapkub รบกวนหน่อยครับ
ใช้แล้วมี error ตามนี้ครับ แก้ยังไงได้บ้างครับ
./node_modules/react-thailand-address-typeahead/src/index.js
Module parse failed: Unexpected token (6:5)
You may need an appropriate loader to handle this file type.
| import AddressTypeahead from './AddressTypeahead.component';
|
| type AddressFormInputPropType = {
| values: {
| a: string;
Code
import React from 'react'
import AddressForm from 'react-thailand-address-typeahead'
export default () => (
<AddressForm onAddressSelected={addressObject => console.log(addressObject)} />
)
ลงด้วยคำสั่ง
yarn add react-thailand-address-typeahead
ลองใช้กับ react-static
และ create-react-app
ครับ เจอแบบเดียวกันทั้งคู่เลยครับ
zapkub commented
@kykungz fix ที่ ebbc6e1 แล้วครับ yarn upgrade react-thailand-address-typeahead@1.0.1
ได้เลยครับ
ขอบคุณครับผม
create-react-app
App.js
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import AddressForm from 'react-thailand-address-typeahead';
class App extends Component {
render() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<h1 className="App-title">Welcome to React</h1>
</header>
<p className="App-intro">
To get started, edit <code>src/App.js</code> and save to reload.
</p>
<AddressForm />
</div>
);
}
}
export default App;
package.json
{
"name": "my-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.4.2",
"react-dom": "^16.4.2",
"react-scripts": "1.1.5",
"react-thailand-address-typeahead": "^1.0.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}