gpt4 book ai didi

javascript - react 组件不渲染

转载 作者:搜寻专家 更新时间:2023-11-01 05:28:14 24 4
gpt4 key购买 nike

我正在构建一个迷你应用程序,以使用 Ryanair 的 API 获取航类日期价格等信息。

我有一个组件可以根据当天是否有航类有条件地呈现 2 个其他组件,但它不起作用。

import React from 'react';
import isFlight from './isFlight';
import noFlight from './noFlight';

function FlightCheck({isflight}){
if(isflight === true){
return <isFlight/>;
}
return <noFlight/>;
}
export default FlightCheck;

最佳答案

您的组件名称需要以大写字母开头。

import IsFlight from './isFlight';
import NoFlight from './noFlight';

<IsFlight/>

<NoFlight/>

This is a JSX tag name convention used to differentiate between built in components and custom components. Built in components start with a lowerCase letter, whereas custom components will start with a upperCase letter

关于javascript - react 组件不渲染,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45601845/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com