如何根据reactjs中从服务器获取的数据显示其他文本

如何根据reactjs中从服务器获取的数据显示其他文本,reactjs,hide,show,Reactjs,Hide,Show,如何根据从服务器获取的数据显示一些其他文本或图标,这里我从服务器获取以下数据,对于所有false参数,我希望显示一些其他文本而不是false,如果有false,则我希望显示一些交叉图标,如果有true,则我希望显示成功图标, 这是我的数据的屏幕截图 这是我用来显示数据的函数 showPrice= () => { debugger; if (this.state.priceList !== undefined) { return this.state.priceList.map(pri

如何根据从服务器获取的数据显示一些其他文本或图标,这里我从服务器获取以下数据,对于所有false参数,我希望显示一些其他文本而不是false,如果有false,则我希望显示一些交叉图标,如果有true,则我希望显示成功图标, 这是我的数据的屏幕截图

这是我用来显示数据的函数

showPrice= () => {
debugger;
if (this.state.priceList !== undefined) {
  return this.state.priceList.map(price => {


    return (

      <tr>
        <td>{price.premiumname}</td>
        <td>dfdf</td>
        <td>{price.expired_time}</td>
        <td>{price.inrprice}</td>

    <td>{price.entertainmentvideo }</td>
        </td>}
        <td>{price.accesslesson}</td>
        <td>{price.exerciselesson}</td>
        <td>{price.lsystem}</td>
        <td>{price.vocabulary}</td>
        <td>{price.materialdownload}</td>
        <td>{price.exclusivewebinars}</td>
        <td>{price.tutoring}</td>
        <td>{price.conversation}</td>
        <td>{price.subscribtion}</td>
        <td>
showPrice=()=>{
调试器;
if(this.state.priceList!==未定义){
返回此.state.priceList.map(price=>{
返回(
{price.premiumname}
dfdf
{price.expired_time}
{price.inrprice}
{price.entertainmentvideo}
}
{price.accesslesson}
{price.exerciselesson}
{price.lsystem}
{price.词汇表}
{price.materialdownload}
{price.exclusivewers}
{price.tutoring}
{price.conversation}
{price.subscribtion}
请帮帮我,我是新手
谢谢

让我们假设以下状态,即在
componentDidMount
中调用API后得到更新:

state = { data : null }

componentDidMount(){
     APICall().then(data => this.setState({ data })) 
}
现在,您只需要根据状态的属性呈现文本。例如:

render(){
    <>
        !this.state.data ? <p>Loading</p> : <p>Loaded</p>
    </> 
}  
render(){
!this.state.data?正在加载

:已加载

}
提供错误信息。您是否正在更新render方法中的状态?您的错误告诉您,您尝试更新状态的次数太多,达到了限制。我猜您正在尝试在每次渲染时更新状态?render方法内容有问题,其中包含对函数的调用,该函数未使用cocontroller并使用
setState
。这会导致在安装组件的第一个周期内多次呈现状态,请验证
render
方法,并找出导致此行为的函数,如果您使用组件的其余代码编辑问题,我们可能会提供帮助。是的,我只需要基于属性播放数据
{this.state.EntertmentVideo==“false”?:}
如果EntertmentVide=“false”,那么我想显示一些文本如果==“true”,那么我想显示一些其他文本