Skip to content

Instantly share code, notes, and snippets.

@sairion
Created August 22, 2016 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sairion/1a7576d2f9e327f2cae9b7437b924402 to your computer and use it in GitHub Desktop.
Save sairion/1a7576d2f9e327f2cae9b7437b924402 to your computer and use it in GitHub Desktop.
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