When get build not Render my child components in Layout But when npm state It works right

39 Views Asked by At

Layout components :

1

return (
        <>
            <ToastContainer />
            <div className='font-IranBold'>
                <div className="border-b border-white dark:border-gray-500">
                    <ul className="flex flex-wrap -mb-px text-sm font-medium text-center text-gray-500 dark:text-gray-400">
                        <Tab TabsInfo={TabsInfo} SetTabState={SetTabState} TabState={TabState} />
                    </ul>
                </div>
                <div>
                    {children}
                </div>
            </div>
        </>
    )

Childs components in Layout :

  return (
<>
  <Layout TabsInfo={TabsInfo} SetTabState={SetTabState} TabState={TabState}>
    {
      TabState === 1 ? <Contentfa AdminAboutFa={AdminAboutFa} /> : <Contenten AdminAboutEn={AdminAboutEn} />
    }
  </Layout>
</>

)

When I run the project with npm start There is no problem and it runs. When I build, it only displays the names of the components :

When run with npm start (open to show)

But :

When get build (open to show)

1

There are 1 best solutions below

0
On

Will need more info to suggest a solution. Especially what do you mean by this

When I run the project with npm start There is no problem and it runs. When I build, it only displays the names of the components :

since the code only executes on npm run start, npm run build is only for bundling the code, we still need to start the app to see anything on the frontend.