我有以下内容:
class PeopleByNameQueryComponent extends Query<FindPeopleByNameQuery, FindPeopleByNameQueryVariables> { }
export const PeopleByNameQuery = (props: any) => {
const { children, ...otherProps } = props;
return <PeopleByNameQueryComponent query={FIND_PEOPLE_QUERY} variables={props.variables} {...otherProps}>
...
</PeopleByNameQueryComponent>;
}
我想将代码简化为:
export const PeopleByNameQuery = (props: any) => {
const { children, ...otherProps } = props;
const ClassToUse = GenericQueryClass extends Query<props.FindQuery, props.QueryVariables> { }
return <ClassToUse query={FIND_PEOPLE_QUERY} variables={props.variables} {...otherProps}>
</ClassToUse>;
}
我不太确定这是否可行,最终目标是减少为完成同一件事而编写的代码量,因此会有很多查询。