// modules/NavLink.js
import React from 'react'
import { Link } from 'react-router'
export default React.createClass({
render() {
//for example this.props={from: "home", to: "about"}
return <Link {...this.props} activeClassName="active"/> // ???what does the statement compile to es5?
}
})
// modules/App.js
import NavLink from './NavLink'
// ...
<li><NavLink to="/home">Home</NavLink></li>
The quesion is below:
<Link {...this.props} activeClassName="active"/>
, what does the statement compile to es5, if this.props={to: "/home", children: "Home"}?
Straight from the Babel homepage :
React.createElement(Link, _extends({}, this.props, { activeClassName: "active" }));
I omitted the _extends
polyfill, it basically resolves to Object.assign
if it is available.
<Link to="/home" children="Home" activeClassName="active"/>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.