Skip to content

Instantly share code, notes, and snippets.

@Arfey
Last active January 15, 2019 23:06
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 Arfey/69f92a3182e6f859cc4a96716f93b7fc to your computer and use it in GitHub Desktop.
Save Arfey/69f92a3182e6f859cc4a96716f93b7fc to your computer and use it in GitHub Desktop.
import * as React from 'react';
type ComponenProps = {
a: string;
};
export function withLikeActions<T extends ComponenProps>(Component: React.ComponentType<T>): React.SFC<T> {
return (props: T) => (
<Component {...props} />
);
}
// first
type arrProps = {
a: number;
};
const arr: React.SFC<arrProps> = () => (<div>text</div>);
// err
withLikeActions(arr);
// second
type arrProps2 = {
};
const arr2: React.SFC<arrProps2> = () => (<div>text</div>);
// success
withLikeActions(arr2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment