如果在反应中满足条件,如何将 const 变量重新分配为 true

Tei*_*eah 1 reactjs react-native next.js

如果反应中满足条件,如何将 const 重新分配为 true?它不断显示错误“displayInternalForm”已声明,但其值从未被读取

export async function getStaticProps({ params }) {

  const displayInternalForm = false;

  const internalJob = internalcategory.categories.find((cat) => 
                      cat.id?.includes("a5c26877-e89c-440b-b7a0-31552865fff5"));

  if (internalJob !== undefined) {
    // It is not reading this line of code. 
    const displayInternalForm = true;
  }

}
Run Code Online (Sandbox Code Playgroud)

TRI*_*IIX 6

let如果重新分配变量,则应该使用。

在这里阅读更多内容

export async function getStaticProps({ params }) {

  let displayInternalForm = false;

  const internalJob = internalcategory.categories.find((cat) => 
                      cat.id?.includes("a5c26877-e89c-440b-b7a0-31552865fff5"));

  if (internalJob !== undefined) {
    // It is not reading this line of code. 
   displayInternalForm = true;
  }

}
Run Code Online (Sandbox Code Playgroud)