Skip to content

Instantly share code, notes, and snippets.

@alesanabriav
Created February 21, 2017 15:16
Show Gist options
  • Save alesanabriav/c356f616c178da7277852f8a3f627d26 to your computer and use it in GitHub Desktop.
Save alesanabriav/c356f616c178da7277852f8a3f627d26 to your computer and use it in GitHub Desktop.
import React from "react";
import { render } from "react-dom";
export default function multipleRender(selector, component) {
if (document.querySelectorAll(selector).length >= 1) {
let forms = [...document.querySelectorAll(selector)];
forms.forEach(el => {
let props = el.getAttribute("data-props")
? JSON.parse(el.getAttribute("data-props"))
: {};
render(React.createElement(component, { ...props }), el);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment