使用Typescript时React.memo不可用吗?

时间:2019-09-04 12:14:20

标签: reactjs typescript

我试图像这样使用React.memo:

const Node: React.memo<Props> = props => {

但是我收到一个错误消息:

Namespace '../ui/node_modules/@types/react/index.d.ts"' has no exported member 'memo'.

但是我可以在index.d.ts中看到备忘录功能:

function memo<P extends object>(
    Component: SFC<P>,
    propsAreEqual?: (prevProps: Readonly<PropsWithChildren<P>>, nextProps: Readonly<PropsWithChildren<P>>) => boolean
): NamedExoticComponent<P>;

function memo<T extends ComponentType<any>>(
    Component: T,
    propsAreEqual?: (prevProps: Readonly<ComponentProps<T>>, nextProps: Readonly<ComponentProps<T>>) => boolean
): MemoExoticComponent<T>;

我在这里想念什么?

1 个答案:

答案 0 :(得分:2)

如注释中所述,@contains(pipeline().parameters.a2,item()) 不是类型声明。您的语法有点混乱

a3

请注意,public async Task<string> AsyncSBSystemApps() { using (var scope = _scopeFactory.CreateScope()) { using (SqlConnection connection = new SqlConnection(connectionString)) { SqlCommand command = new SqlCommand(@"SELECT a.app_guid as AppGuid, a.name as AppName, a.state as AppState, a.created_at as AppCreatedAt, a.updated_at as AppUpdatedAt, a.foundation as AppFoundation, s.name as SpaceName, o.name as OrgName FROM apps as a INNER JOIN spaces as s ON a.space_guid = s.space_guid INNER JOIN organizations as o ON s.org_guid = o.org_guid where s.name = 'system' and o.name = 'system' and a.foundation = 2", connection); await connection.OpenAsync(); string result = (string)command.ExecuteScalar() ; return result; } } 是功能组件的声明。由于您将其包装在memo中,因此可能需要更改类型。但就我个人而言,我并不需要。