ฉันกำลังพยายามแสดงส่วนประกอบคอนเทนเนอร์และใช้เราเตอร์ react เวอร์ชันเก่ากว่าที่ฉันเคยเห็นคนทำสิ่งนี้:
const AppRouter = () => (
<Router component={App}>
<Route exact path="/" component={Dashboard} />
</Router>
);
องค์ประกอบแอปของฉันมีลักษณะอย่างไร:
import React, { PropTypes } from 'react';
class App extends React.Component {
render() {
return (
<div>
<p>Hello...</p>
{this.props.children}
</div>
);
}
}
export default App;
package.json ของฉันมีสิ่งนี้ในปัจจุบัน:
dependencies": {
"history": "^4.7.2",
"moment": "^2.20.1",
"react": "^16.2.0",
"react-dnd": "^2.5.4",
"react-dnd-html5-backend": "^2.5.4",
"react-dom": "^16.2.0",
"react-redux": "^5.0.6",
"react-router": "^4.2.0",
"react-router-dom": "^4.2.2",
"react-router-redux": "^4.0.8",
"redux": "^3.7.2",
"redux-thunk": "^2.2.0"
},
BTW ฉันจำเป็นต้องนำเข้า react-router และ react-router-dom และ react-router-redux เมื่อใช้ react-router 4.2 หรือไม่