我在reactjs中得到了一个非常不寻常的错误,它说instance.render不是reactjs中的一个函数,.I无法跟踪这个错误。这是index.js文件,也是我在component中唯一拥有的其他文件。
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import SearchBar from './components/search_bar.js';
const API_KEY='AIzaSyA4c4bzl1At2c0IAJXU939D1vAIUwAn3Ss';
const App = ()=>{
return(
<div>
<SearchBar/>
</div>
);
}
ReactDOM.render(<App />, document.getElementById('root'));
这是组件文件夹中搜索栏中的search_bar.js。
import React, { Component } from 'react';
class SearchBar extends React.Component{
constructor(props){
super(props);
this.state={
term:''
};
this.onInputchange=this.onInputchange.bind(this);
}
onInputchange(event){
console.log(event);
}
render(){
return(
<div className="search_bar">
<input
onChange={this.onInputchange}
/>
</div>
);
}
}
export default SearchBar;
https://stackoverflow.com/questions/50651512
复制相似问题