searchbar
组件将搜索值传递给menubar
组件以进行自定义搜索App(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.
componentWillRecieveProps
https://codesandbox.io/s/eloquent-galileo-14874
class App extends Component {
state = {
groupCheckBoxValues: [],
groupRadioValue: "PRO"
};
componentWillReceiveProps({ search }) {
console.log(search);
}
componentDidMount() {
this.fetchdata("story");
}
fetchdata(type = "", search_tag = "") {
var url = "https://hn.algolia.com/api/v1/search?tags=";
fetch(`${url}${type}&query=${search_tag}`)
.then(res => res.json())
.then(data => {
this.props.getData(data.hits);
});
}
render() {
<div> testing</div>;
}
}
const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);
只需将渲染函数更改为:
render() {
return <div> testing</div>;
}
其余的保持不变。如果您需要任何帮助或这不起作用,请大喊大叫!
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句