MicheleBertoli / React Render With Params
Licence: mit
The render method you've always wanted
Stars: ✭ 25
Programming Languages
javascript
184084 projects - #8 most used programming language
react-render-with-params
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.
Installation
npm i react-render-with-params --save
Usage
import 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'))
Test
npm test
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].