useLocation我对 React Router以及如何获取当前路径名有一些问题。
这就是我正在做的:
import {BrowserRouter as Router, Switch, Route, Link} from "react-router-dom";
import {useHistory, useLocation} from 'react-router-dom'
function Home(props) {
const [isHome, setIsHome] = useState(true);
const [isContents, setIsContents] = useState(false);
const [isUserProfile, setIsUserProfile] = useState(false);
let location = useLocation();
let history = useHistory();
console.log(location)
console.log(history)
function getCurrentLocation() {
}
function logout() {
const logger = fetch('/users/logout');
logger.then(logout => {
if (logout.ok) {
props.logout()
} else {
console.log('error', logout);
}
})
}
return (
<Router>
<div className={'container-fluid h-100'}>
<div …Run Code Online (Sandbox Code Playgroud) webpack devServer将我的项目包从更新为 后,"webpack-dev-server": "3.11.2"当"webpack-dev-server": "4.3.0"我启动项目时,我遇到了这个问题:
>> npm run start
> backoffice@1.0.0 start
> webpack serve --config webpack.dev.js
[webpack-cli] Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
- options has an unknown property 'writeToDisk'. These properties are valid:
object { allowedHosts?, bonjour?, client?, compress?, devMiddleware?, headers?, historyApiFallback?, host?, hot?, http2?, https?, ipc?, liveReload?, magicHtml?, onAfterSetupMiddleware?, onBeforeSetupMiddleware?, onListening?, open?, port?, proxy?, setupExitSignals?, static?, watchFiles?, webSocketServer? } …Run Code Online (Sandbox Code Playgroud)