[英]In react I had created wrapper components.So now i need to use them in my app.tsx in element parameter which is in route tag.But error as not jsx elem
'Catalog' cannot be used as a JSX component. “目录”不能用作 JSX 组件。 Its return type 'CatalogState' is not a valid JSX element.
它的返回类型“CatalogState”不是有效的 JSX 元素。 Type 'CatalogState' is missing the following properties from type 'ReactElement<any, any>': type, props, keyts(2786)
“CatalogState”类型缺少“ReactElement<any,any>”类型的以下属性:类型、道具、keyts(2786)
here catalog is my wrapper component THIS IS THE ROUTE PART WHERE I AM USING CATALOG AS A WRAPPER COMPONENT这里目录是我的包装器组件这是我使用目录作为包装器组件的路线部分
<Routes>
{/* <Route path={BASE}/></Catalog> */}
{/* <Route path={BASE} element={<PrimeCatalogContainer/>} /> */}
<Route path={BASE} element={()=>(<Catalog><PrimeCatalogContainer/></Catalog>)}/>
<Route path={PRIME_CATALOG} element={<PrimeCatalogContainer />} />
<Route path={PRIME_TRAINING} element={<PrimeTrainingPage />} />
<Route path={PRIME_INSTANCE} element={<PrimeInstancePage />} />
<Route path={PRIME_ALMPROFILE} element={<ALMProfilePage />} />
<Route
path={PRIME_BOARDPAGE}
element={<PrimeCommunityBoardPage />}
/>
<Route
path={PRIME_BOARDLIST}
element={<PrimeCommunityBoardList />}
/>
</Routes>
CATALOG COMPONENT目录组件
import { PrimeCatalogContainer } from "./almLib";
const Catalog = () =>{
return(
<>
<div
className="catalog_container"
data-show-filters="true"
data-show-search="true"
data-catalogs="true"
data-lo-types="true"
data-skill-name="true"
data-lo-format="true"
data-duration="true"
data-price="true"
data-skills-level="true"
data-learner-state="true"
data-tag-name="true"
data-skill-level="true"><PrimeCatalogContainer/>
</div>
</>
);
};
instead of above catalogcomponent I tried below one also而不是上面的目录组件,我也尝试了下面的一个
import { PrimeCatalogContainer } from "./almLib";
function Catalog (): JSX.Element {
return(
<div
className="catalog__container"
data-show-filters="true"
data-show-search="true"
data-catalogs="true"
data-lo-types="true"
data-skill-name="true"
data-lo-format="true"
data-duration="true"
data-price="true"
data-skills-level="true"
data-learner-state="true"
data-tag-name="true"
data-skill-level="true"
><PrimeCatalogContainer/></div>
);
};
As stated in the docs , element
should be a ReactNode, so instead of:如文档中所述,
element
应该是一个 ReactNode,而不是:
<Route path={BASE} element={()=>(<Catalog><PrimeCatalogContainer/></Catalog>)}/>
you need to return the actual Catalog您需要返回实际的目录
<Route path={BASE} element={<Catalog><PrimeCatalogContainer/></Catalog>}/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.