close

React.jpg

 

繼上一個問題解決後,又遇到了另一個問題,依舊是下述這段程式碼,但是遇到的是不同的錯誤。

1.JPG

 

錯誤描述:

1.JPG

Warning: Functions are not valid as a React child. This may happen if you return a Component instead of <Component /> from render. Or maybe you meant to call this function rather than return it.

簡單來說,就是使用元件的方式錯誤,上例中,本來是function component ToDoPage,硬是被我用錯誤的方式引用,所以上述的程式只要改成:

<Route exact path="/" element={<ToDoPage/>} />

就可以正常顯示了。

 

正常畫面如下:

2.JPG

arrow
arrow
    全站熱搜

    葛瑞斯肯 發表在 痞客邦 留言(0) 人氣()