Skip to content

Instantly share code, notes, and snippets.

@yazonnile yazonnile/component.jsx Secret
Last active Jun 15, 2019

Embed
What would you like to do?
const sayHello = () => 'Hello, world';
const AddHelloMethod = ({ children }) => {
return React.Children.map(children, child => {
return React.cloneElement(child, { sayHello });
});
}
interface INested {
sayHello(): string;
}
const Nested = ({ sayHello }: INested) => {
return (
<button onClick={sayHello}>Click me!</button>
)
}
const App = () => {
// TS error on 23 line. sayHello method required for Nested */}
return (
<AddHelloMethod>
<Nested />
</AddHelloMethod>
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.