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
Alex Indigo e401e2cf5f Added IoC example (#3595)
* Added `with-ioc` example

* pre-compile deps until we get nextjs magic working
2018-01-31 08:36:20 +01:00

30 lines
803 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>
)
}
}