Created
August 22, 2016 10:29
-
-
Save sairion/1a7576d2f9e327f2cae9b7437b924402 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ReactDOM from 'react'; | |
// render without using JSX | |
export function jsRender(Component, data={}, targetElement, callback=null) { | |
ReactDOM.render(<Component {...data} />, targetElement, callback) | |
} | |
// Render after specific element. | |
export function wrappedRenderCreator( | |
$WrapperMethodKey/* appendTo, prependTo, insertAfter, insertBefore, ... */, | |
Component, | |
data, | |
targetElement, | |
element='div' | |
) { | |
let wrapper = $(`<${element} />`)[$WrapperMethodKey](targetElement); | |
return function renderAfter() { | |
return jsRender(Component, data, wrapper); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment