我想基于外部条件渲染组件,否则重定向应用程序中的其他位置.
理想情况下,此重定向将在组件之前确定,但在某些情况下,我觉得我需要在组件中执行此操作.例如,在ReactRouter中,路由器可能如下所示:
<Router>
<Route path='/' component={LoadingPage} />
<Route path='/Home' component={HomePage} />
<Route path='/Login' component={LoginPage} />
</Router>
Run Code Online (Sandbox Code Playgroud)
和LoadingPage的逻辑/ sudocode将是这样的:
if (stillLoading) {
render
} else if (loggedIn) {
redirectToHome
} else {
redirectToLogin
}
Run Code Online (Sandbox Code Playgroud)
它变得复杂,因为有时在请求组件之前已经加载了应用程序.
什么生命周期阶段是放置此重定向逻辑的最合适的位置?
我已经使用 option 启动了一个容器--rm,例如:
docker run --rm -it --name test bash
Run Code Online (Sandbox Code Playgroud)
但现在我想保持容器退出。有没有办法取消--rm已经运行的容器上的选项?
许多网站编写的代码破坏了用户设置自己的字体大小(在浏览器/移动设备的设置中)的能力。为了避免这种情况,当用户更改默认字体大小时,技术层面上到底会发生什么?它有什么影响?
html元素font-sizeCSS 中指定的它会扩展或覆盖这个吗?em, px,rem , %?vh, vw, vmin,vmax对于那些尝试进行流体排版的人来说calc()?但是,以下内容均不涉及规范,而只是特定行为的集合。
当我遇到合并冲突并键入时,git ls-files --modified我希望它会显示在当前合并冲突中修改的文件列表,并且只显示一次文件。但有时它会显示多次列出的同一个文件。例如,当我执行以下操作时:
git init
git commit --allow-empty -m 'init'
echo hello world > file
git add -A
git commit -m "hello world"
git checkout HEAD^
git checkout -b other
echo hello other > file
git add -A
git commit -m "hello other"
git merge master
# Generates conflict
git ls-files --modified
Run Code Online (Sandbox Code Playgroud)
表明
file
file
Run Code Online (Sandbox Code Playgroud)
当 git status 只显示file一次时。
在这种情况下,它列出了两次相同的文件,但我有几次它列出了 3 次相同的文件。
这是预期的行为吗?