首页 > 解决方案 > 绑定元素'children'隐式具有'any'类型

问题描述

我注意到下面的代码应该是js编码风格,我怎么能用这种tsx风格写?

import React, { Children } from 'react';
import { Text, StyleSheet } from 'react-native';


export function Heading ({children, props}){
    return <Text{...props}>{children}</Text>
}

标签: typescriptreact-native

解决方案


试试这个代码

    export function Heading ({children, props}:{children:any,props:any}){
        return <Text{...props}>{children}</Text>
    }

推荐阅读