problem description
detailed error information:
. / src/component/Login.js
Line 13: "inject" is not defined no-undef
Search for the keywords to learn more about each error.
the environmental background of the problems and what methods you have tried
using mobx-react "s inject causes an error to run
related codes
/ / Please paste the code text below (do not replace the code with pictures)
Login.js code is as follows:
/ *
- Created by 20161221 on 2018-12-24.
* /
/ *
- Created by 20161221 on 2018-12-24.
* /
import React, {Component} from "react";
import {
Button, Form, FormGroup, Label, Input, FormText
} from "reactstrap";
import {observer} from "mobx-react";
@ inject ("store")
@ observer
export default class Login extends Component {
constructor(props) {
super( props );
this.state = {"email":"598643474@qq.com","password":""};
}
change(){
this.setState({"email":"583513772@qq.com"});
}
login(){
this.props.store.login(this.state.email,this.state.password);
}
handleChange(e , field){
console.log("in change "+field+ e.target.value);
let o = {};
o[field] = e.target.value;
this.setState(o)
}
render(){
return(
<div>
<h1 class="page-title"></h1>
<Form>
<FormGroup>
<Input type="email" name="email" placeholder="Email" value={this.state.email} onChange={(e)=>this.handleChange(e,"email")} />
</FormGroup>
<FormGroup>
<Input type="password" name="password" placeholder="(6-12)" value={this.state.password} onChange={(e)=>this.handleChange(e,"password")} />
</FormGroup>
<FormGroup>
<Button color="primary" onClick={()=>this.login()}></Button>
</FormGroup>
</Form>
</div>
)
}
}
/ *
< FormGroup >
< Input type= "email" name= "email" placeholder= "Email" value= {this.state.email} onClick= {() = > this.change ()} / >
< / FormGroup >
* /
index.js code is as follows:
import React from "react";
import ReactDOM from" react-dom";
import". / index.css";
import App from". / App";
import * as serviceWorker from". / serviceWorker";
import {Provider} from "mbox-react";
import AppState from". / store/AppState";
ReactDOM.render (
)<Provider store = {AppState}><App /></Provider>
, document.getElementById ("root"));
/ / If you want your app to work offline and load faster, you can change
/ / unregister () to register () below. Note this comes with some pitfalls.
/ / Learn more about service workers: http://bit.ly/CRA-PWA
serviceWorker.unregister();
package.json code is as follows:
{
"name": "client",
"version": "0.1.0",
"private": true,
"dependencies": {
"bootstrap": "^4.0.0",
"jquery": "^3.3.1",
"mobx": "^4.1.0",
"mobx-react": "^5.0.0",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-router-dom": "^4.2.2",
"react-scripts": "1.1.1",
"react-transition-group": "^2.2.1",
"reactstrap": "^4.8.0"
},
"scripts": {
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"test": "react-app-rewired test --env=jsdom",
"eject": "react-scripts eject"
},
"devDependencies": {
"react-app-rewire-mobx": "^1.0.7",
"react-app-rewired": "^1.5.0"
}
}
what result do you expect? What is the error message actually seen?
I hope the inject can be executed successfully