我知道如何在以前版本的React Router中做到这一点,但我绝对不知道如何在新的React Router v4中做到这一点.有人能帮助我吗?
<Link>Image as modal</Link>用状态点击时modal: true,带有图像的模态会出现但是后面的模态必须是浏览器中的前一个内容+网址=== /图像/ 1 ...然后如果按F5,页面将正常显示.示例:instagram ...等
码:
const Images = (props) => {
return (
<div>
<h2>Images</h2>
<ul>
<li><Link to={{
pathname: '/image/1',
state: {
modal: true
}
}}>Image as modal</Link></li>
<li><Link to="/image/2">Image</Link></li>
</ul>
</div>
)
}
const Image = (props) => {
return (
<div>
<h2>Image {props.match.params.id}</h2>
<ul>
<li><Link to="/images">Back to Images</Link></li>
</ul>
</div>
)
}
ReactDOM.render(
<Provider store={store}>
<Router>
<div>
<Route path='/images' component={Images} …Run Code Online (Sandbox Code Playgroud) 我按照你推荐我的一切,让Babel 7与Jest一起工作.我安装了@babel/core和babel-core.仍然没有用.
{
"devDependencies": {
"@babel/cli": "^7.0.0-beta.51",
"@babel/core": "^7.0.0-beta.51",
"@babel/node": "^7.0.0-beta.51",
"@babel/plugin-transform-modules-commonjs": "^7.0.0-beta.51",
"@babel/preset-flow": "^7.0.0-beta.51",
"babel-core": "^7.0.0-beta.51",
"jest-cli": "^23.1.0"
}
}
Run Code Online (Sandbox Code Playgroud)
后 yarn jest
yarn run v1.9.0-20180612.1255
$ /Users/m/Desktop/k/node_modules/.bin/jest
FAIL packages/services/src/Client/__tests__/Client.js
- Test suite failed to run
Requires Babel "^7.0.0-0", but was loaded with "6.26.3". If you are sure you have a compatible version of @babel/core, it is likely that something in your build process is loading the wrong version. Inspect the stack trace of this …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建软件,该软件将
JSX使用缩小的打字稿类型记录文件的所有属性。
test的属性div定义为{test:'hello'}因此仅接受hello单词作为string
const testAsConst = 'hello' as const;
const test = 'hello';
// both variables above works
<div test={test} />;
Run Code Online (Sandbox Code Playgroud)
预期输出:[ [ 'test', '"hello"' ] ]
没有as const输出的是[ [ 'test', 'string' ] ]
输出as const是[ [ 'test', '"hello"' ] ]
这一
but章的内容已经很明显了。我知道as const做了什么。但是这个例子可以工作吗,as const因为没有打字稿报告没有错误,所以它是hello而不是string没有as const......我希望你理解。
import typescript from …Run Code Online (Sandbox Code Playgroud) babel ×1
babel-jest ×1
javascript ×1
jestjs ×1
react-router ×1
reactjs ×1
typescript ×1
yarnpkg ×1