如何 return 函数中的缺点反应本机?

how to return cons in a function react native?

我需要 return 函数中的常量。这是我的代码:

ValidarSections(){
    if(global.titulo === "Telefonia - Implementaciones"){
      return  SECTIONS = [
        {
          title: "Milestone",
          content: this.state.Milestone
        }
      ]
    }

    if(global.titulo === "Telefonia - Integraciones"){
      return SECTIONS = [
        {
          title: "Relevamiento",
          content: this.state.RelevamientoINT
        },
        {
          title: "Instalaciones",
          content: this.state.Instalaciones
        },
        {
          title: "Integraciones",
          content: this.state.Integracion
        }
      ]
    }

    if(global.titulo === "Obras Civiles"){
      return SECTIONS = [
        {
          title: "Obra",
          content: this.state.Obra
        },
        {
          title: "Relevamiento",
          content: this.state.RelevamientoOBR
        }
      ]
    }
  }


  render() {
    const SECTIONS = this.ValidarSections()
    ....
   }

能够在 Accordion 库中使用这个常量。 我是 React Native 的新手,我能做到吗?

您 return 不是常量,您 return 是一个值。从 return 语句中删除 SECTIONS =

ValidarSections(){
    if(global.titulo === "Telefonia - Implementaciones"){
      return [
        {
          title: "Milestone",
          content: this.state.Milestone
        }
      ]
    }

    if(global.titulo === "Telefonia - Integraciones"){
      return [
        {
          title: "Relevamiento",
          content: this.state.RelevamientoINT
        },
        {
          title: "Instalaciones",
          content: this.state.Instalaciones
        },
        {
          title: "Integraciones",
          content: this.state.Integracion
        }
      ]
    }

    if(global.titulo === "Obras Civiles"){
      return [
        {
          title: "Obra",
          content: this.state.Obra
        },
        {
          title: "Relevamiento",
          content: this.state.RelevamientoOBR
        }
      ]
    }
  }


  render() {
    const SECTIONS = this.ValidarSections()
    ....
   }