Mar 10, 2023 - 2 min read
1import React from "react";
2
3export const Label = ({ color, size }: { color: string, size: string }) => {
4 return (
5 <div>
6 <p style={{ color: color, fontSize: size }}>Hello World</p>
7 </div>
8 );
9};
10
11export const partialComponent = (Component: React.FC, partialProps: any) => {
12 return (props: any) => {
13 return <Component {...partialProps} {...props} />;
14 };
15};
16
17const RedTitle = partialComponent(Label, { color: "red" });
18
19export const DemoPartialComponent = () => {
20 return <RedTitle size="20px" />;
21};