📌  相关文章
📜  useHistory - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:02.145000             🧑  作者: Mango

代码示例2
import { useLocation } from 'react-router-dom'

// Location is, for example: http://localhost:3000/users/new

// Care! MyComponent must be inside Router to work
const MyComponent = () => {
    const location = useLocation()
    
    // location.pathname is '/users/new'
    return Path is: {location.pathname}
}

export default MyComponent