1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00
next.js/examples/with-ioc/components/endpoint.js
Tim Neutkens 9c4eefcdbf
Add prettier for examples directory (#5909)
* Add prettier for examples directory

* Fix files

* Fix linting

* Add prettier script in case it has to be ran again
2018-12-17 17:34:32 +01:00

40 lines
895 B
JavaScript

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
}
render() {
const { Link } = this.props
return (
<div
style={{
marginTop: '5px',
border: '1px dashed #00ff00',
padding: '10px'
}}
>
<h3>Endpoint</h3>
Uses injected `Link` component without direct dependency on one
<br />
<Link route="about" params={{ foo: 'baz' }}>
<a>About: foo baz</a>
</Link>
<br />
<Link route="/">
<a>go Home</a>
</Link>
</div>
)
}
}