我在下面遇到这个问题:
Line 5: Your render method should have return statement react/require-render-return
我假设ReactDom.render()在无状态组件上返回null。
import React from 'react';
import ReactDOM from 'react-dom';
import { BrowserRouter, Match, Miss } from 'react-router';
import SearchBar from './components/SearchBar.js'
const Root = () => {
return(
<div className="searchbar"> <SearchBar/> </div>
)
}
ReactDOM.render(
<Root />, document.querySelector('#searchbar')
)
谢谢!
答案 0 :(得分:0)
看起来return
和(
const Root = () => {
return (
<div className="searchbar"> <SearchBar/> </div>
)
}
(或)
const Root = () => <div className="searchbar"> <SearchBar/> </div>;
答案 1 :(得分:0)
你的Root组件没问题。问题可能在于你没有发布的SearchBar组件......
(&#39; return&#39;和&#39;之间应该有空格(&#39;但它似乎不会导致错误)。