Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Typescript 类型';FC<;客户行动计划>';不可分配给类型';(道具:自定义步骤道具)_Typescript - Fatal编程技术网

Typescript 类型';FC<;客户行动计划>';不可分配给类型';(道具:自定义步骤道具)

Typescript 类型';FC<;客户行动计划>';不可分配给类型';(道具:自定义步骤道具),typescript,Typescript,这是我的代码 interface CustomStepProps { isComplete: boolean; currentStep?: number; stepIndex?: number; cantBack?: boolean; isInFinalStep?: boolean; backHandler?: () => void; nextHandler?: () => void; } const Loki: React.

这是我的代码

interface CustomStepProps {
    isComplete: boolean;
    currentStep?: number;
    stepIndex?: number;
    cantBack?: boolean;
    isInFinalStep?: boolean;
    backHandler?: () => void;
    nextHandler?: () => void;
}

const Loki: React.FC<{
    steps: Step[];
    onFinish: () => void;
    backLabel?: string | React.ReactElement | React.ReactComponentElement;
    nextLabel?: string | React.ReactElement | React.ReactComponentElement;
    finishLabel?: string | React.ReactElement;
    noActions?: boolean;
    renderSteps?: (props: CustomStepProps) => React.ReactElement;
    renderActions?: (props: CustomStepProps) => React.ReactElement;
    renderComponents?: (props: CustomStepProps) => React.ReactElement | React.ReactComponentElement;
}>;

export interface CustomActionsProps {
    isComplete: boolean;
    cantBack: boolean;
    isInFinalStep: boolean;
    backHandler: () => void;
    nextHandler: () => void;
}
const CustomActions: React.FC<CustomActionsProps> = (props) => {
    const { isComplete, cantBack, isInFinalStep, backHandler, nextHandler } = props;
    return (
        <div className="button-group">
            <button
                type="button"
                className="btn btn-secondary btn-sm"
                onClick={backHandler}
                disabled={cantBack || isComplete}
            >
                Go back
            </button>
            <button
                type="button"
                className="btn btn-outline-primary btn-sm"
                onClick={nextHandler}
                disabled={isComplete}
            >
                {isInFinalStep ? `Finish HIM` : `Go Next`}
            </button>
        </div>
    );
};
const Stepper: React.FC<StepProps> = (props) => {
    const { setFinish } = props;
    return (
        <div>
            <Loki steps={objectStep} onFinish={setFinish} renderActions={CustomActions} />
        </div>
    );
};

界面自定义步骤道具{
isComplete:布尔值;
当前步骤?:编号;
步骤索引?:编号;
坎背?:布尔值;
isInFinalStep?:布尔值;
backHandler?:()=>void;
nextHandler?:()=>无效;
}
const Loki:React.FC void;
backLabel?:字符串| React.ReactElement | React.ReactComponentElement;
nextLabel?:字符串| React.ReactElement | React.ReactComponentElement;
finishLabel?:字符串| React.ReactElement;
noActions?:布尔值;
renderSteps?:(道具:CustomStepProps)=>React.ReactElement;
渲染?:(道具:CustomStepProps)=>React.ReactElement;
renderComponents?:(道具:CustomStepProps)=>React.ReactElement | React.ReactComponentElement;
}>;
导出接口CustomActionsProps{
isComplete:布尔值;
cantBack:布尔型;
isInFinalStep:布尔值;
backHandler:()=>void;
nextHandler:()=>无效;
}
const CustomActions:React.FC=(道具)=>{
const{isComplete,cantBack,isInFinalStep,backHandler,nextHandler}=props;
返回(
回去
{isInFinalStep?`完成他':'下一步走`}
);
};
常量步进器:React.FC=(道具)=>{
const{setFinish}=props;
返回(
);
};
这就是错误:

(JSX attribute) renderActions?: ((props: CustomStepProps) => React.ReactElement<any, string | ((props: any) => React.ReactElement<any, any> | null) | (new (props: any) => React.Component<any, any, any>)>) | undefined
Type 'FC<CustomActionsProps>' is not assignable to type '(props: CustomStepProps) => ReactElement<any, string | ((props: any) => ReactElement<any, any> | null) | (new (props: any) => Component<any, any, any>)>'.
  Types of parameters 'props' and 'props' are incompatible.
    Type 'CustomStepProps' is not assignable to type 'PropsWithChildren<CustomActionsProps>'.
      Type 'CustomStepProps' is not assignable to type 'CustomActionsProps'.
        Types of property 'cantBack' are incompatible.
          Type 'boolean | undefined' is not assignable to type 'boolean'.
            Type 'undefined' is not assignable to type 'boolean'.ts(2322)
react-loki.d.ts(29, 3): The expected type comes from property 'renderActions' which is declared here on type 'IntrinsicAttributes & { steps: Step[]; onFinish: () => void; backLabel?: any; nextLabel?: any; finishLabel?:
(JSX属性)渲染?:((道具:CustomStepProps)=>React.ReactElement React.ReactElement | null)|(新的(道具:任意)=>React.Component)>)|未定义
类型“FC”不可分配给类型“(props:CustomStepProps)=>ReactElement ReactElement | null)|(新的(props:any)=>Component)>”。
参数“props”和“props”的类型不兼容。
类型“CustomStepProps”不可分配给类型“PropsWithChildren”。
类型“CustomStepProps”不可分配给类型“CustomActionsProps”。
属性“cantBack”的类型不兼容。
类型“boolean | undefined”不可分配给类型“boolean”。
类型“undefined”不可分配给类型“boolean”。ts(2322)
react-loki.d.ts(29,3):预期的类型来自属性“renderActions”,该属性在类型“intrinsicatAttribute&{steps:Step[];onFinish:()=>void;backLabel?:any;nextLabel?:any;finishLabel?:

我想我已经声明了它所需的所有道具?我也使用问号作为可选选项,但它仍然会导致我出错。你们能帮我解决这个问题吗?谢谢你们

你们能分享
Loki
组件的代码吗?看起来它可能很重要
界面自定义步骤道具{isComplete:boolean;currentStep?:编号;stepIndex?:编号;cantBack?:boolean;isInFinalStep?:布尔;backHandler?:()=>void;nextHandler?:()=>void;}
const-Loki:React.FC void;backLabel?:string | React.ReactElement | React.ReactComponentElement;nextLabel?:string | React.ReactElement | React.ReactElement;noActions?:布尔;renderSteps?:(道具:CustomStepProps)=>React.ReactElement;renderActions?:(道具:CustomStepProps)=>React.ReactElement;renderComponents?:(道具:CustomStepProps)=>React.ReactElement | React.ReactComponentElement;}>;
很抱歉给您带来不便,但我似乎无法在评论中找到新行。没问题,我将它添加到了原始问题中