2018-01-31 07:36:20 +00:00
|
|
|
import React from 'react'
|
|
|
|
import { inject } from 'ioc'
|
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
|
|
|
|
@inject({
|
|
|
|
// keep it `isRequired`-free to allow mock injection via props
|
|
|
|
Link: PropTypes.func
|
|
|
|
})
|
|
|
|
export default class extends React.Component {
|
|
|
|
static propTypes = {
|
|
|
|
// you can add `isRequired` to the component's propTypes definition
|
|
|
|
Link: PropTypes.func.isRequired
|
|
|
|
}
|
|
|
|
|
2018-12-17 16:34:32 +00:00
|
|
|
render() {
|
2018-01-31 07:36:20 +00:00
|
|
|
const { Link } = this.props
|
|
|
|
|
|
|
|
return (
|
2018-12-17 16:34:32 +00:00
|
|
|
<div
|
|
|
|
style={{
|
|
|
|
marginTop: '5px',
|
|
|
|
border: '1px dashed #00ff00',
|
|
|
|
padding: '10px'
|
|
|
|
}}
|
|
|
|
>
|
2018-01-31 07:36:20 +00:00
|
|
|
<h3>Endpoint</h3>
|
|
|
|
Uses injected `Link` component without direct dependency on one
|
|
|
|
<br />
|
2018-12-17 16:34:32 +00:00
|
|
|
<Link route="about" params={{ foo: 'baz' }}>
|
|
|
|
<a>About: foo baz</a>
|
|
|
|
</Link>
|
2018-01-31 07:36:20 +00:00
|
|
|
<br />
|
2018-12-17 16:34:32 +00:00
|
|
|
<Link route="/">
|
|
|
|
<a>go Home</a>
|
|
|
|
</Link>
|
2018-01-31 07:36:20 +00:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|