I've been using Preact recently and I loved the way props, state and context are passed to the render method. It feels like writing functional components and it's great for destructuring.
That's what the renderWithParams higher order component is about.
npm i react-render-with-params --saveimport React, { PropTypes } from 'react'
import { render } from 'react-dom'
import renderWithParams from 'react-render-with-params'
const Yo = React.createClass({
contextTypes: {
myContext: PropTypes.string,
},
getInitialState() {
return {
myState: 'myState',
}
},
render({ myProps }, { myState }, { myContext }) {
return <div>{myProps} {myState} {myContext}</div>
},
})
const SuperYo = renderWithParams(Yo)
render(<SuperYo myProps="myProps" />, document.getElementById('app'))npm test