亲宝软件园·资讯

展开

解决React报错Functions are not valid as a React child

Borislav Hadzhiev 人气:0

总览

产生"Functions are not valid as a React child. This may happen if you return a Component instead of <Component /> from render."错误

通常是因为以下两个原因:

这里有个例子来展示错误是如何发生的。

// App.js
/**
 * ⛔️ 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.
 */
const App = () => {
  const getButton = () => {
    return <button>Click</button>;
  };
  // 

加载全部内容

相关教程
猜你喜欢
用户评论