我試圖在我的Next.js應用程序中實現tabs from semantic-ui。Next.js和語義UI,選項卡元素,錯誤:元素類型無效
我收到此錯誤:
Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in. Check the render method of
TabExampleBasic
.
這是代碼:
import React from 'react'
import { Tab } from 'semantic-ui-react'
const panes = [
{ menuItem: 'Tab 1', render:() => <Tab.Pane>Tab 1 Content</Tab.Pane> },
{ menuItem: 'Tab 2', render:() => <Tab.Pane>Tab 2 Content</Tab.Pane> },
{ menuItem: 'Tab 3', render:() => <Tab.Pane>Tab 3 Content</Tab.Pane> },
]
const TabExampleBasic =() => (
<Tab panes={panes} />
)
export default TabExampleBasic
我進口這個組件到頁/ index.js。來自語義用戶界面的其他組件,如Card,Grid或Accordion確實可以毫無麻煩地工作。
我用這個例子的工作:https://github.com/zeit/next.js/tree/master/examples/with-semantic-ui
「semantic-ui-react」是否正確安裝?在導入後嘗試'console.log(Tab);'。如果它顯示未定義這裏是問題。 –
你說得對,有問題。我重新安裝了它,現在它可以工作。 – danieljacky