Skip to content

Instantly share code, notes, and snippets.

@silicakes
Created December 31, 2018 16:52
Show Gist options
  • Save silicakes/46944c5e3db7c666e97504a8bffb3c12 to your computer and use it in GitHub Desktop.
Save silicakes/46944c5e3db7c666e97504a8bffb3c12 to your computer and use it in GitHub Desktop.
import * as React from "react";
import { render } from "react-dom";
import "./styles.css";
function App(props) {
return (
<div className="App">
<h1> {props.text}</h1>
</div>
);
}
const override = props => ({ text: "cat" });
const hoc = Component => React.cloneElement(Component, override(Component.props));
const rootElement = document.getElementById("root");
render(hoc(<App text="dog" />), rootElement);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment