0
import React from 'react';
import ReactDOM from 'react-dom';
import { BrowserRouter } from 'react-router-dom';
import App from './components/App';
import registerServiceWorker from './registerServiceWorker';
ReactDOM.render(
<BrowserRouter>
<App />
</BrowserRouter>,
document.getElementById('root')
);
registerServiceWorker();
我需要能夠訪問App
組件中的location
prop。我想知道是否有可能讓Router
組件將其history
道具傳遞給子組件App
。如何訪問React路由器的位置道具?