import React, { Component } from 'react';
import PropTypes from 'prop-types';
import axios from 'axios';
import { connect } from 'react-redux';
import * as actions from '../../reducks/auth/actions';
import CircularProgress from "@material-ui/core"
class Add_Want_Item_Form extends Component {
constructor(props) {
super(props);
this.state = {
// #インプット情報用
info: {
name: '',
owner: '',
keyword1: '',
keyword2: '',
keyword3: '',
bland: '',
url: '',
},
// Validation用
// urlは必須項目ではないのでValidationには含めない
message: {
name: '',
keyword1: '',
keyword2: '',
keyword3: '',
bland: '',
},
};
this.handleChange = this.handleChange.bind(this);
}
componentDidMount() {
axios
.get('http://localhost:8000/api/user/' + this.state.uid)
.then((res) => console.log(res))
.catch((err) => console.log(err));
}
handleChange(e) {
const name = e.target.name;
const value = e.target.value;
const { info, message } = this.state;
this.setState({
info: { ...info, [name]: value },
});
this.setState({
message: { ...message, [name]: this.validator(name, value) },
});
}
////
...
////
render() {
const { info, message } = this.state;
return (
<div>
<label>商品名</label>
<input name="name" type="text" value={this.state.info.name} onChange={this.handleChange} />
<p>{this.state.message.name}</p>
</div>
);
}
}
const mapStateToProps = (state) => {
return {
uid: state.uid,
};
};
export default connect(mapStateToProps)(Add_Want_Item_Form);
super
gets strikethrough in React although that doesn't show up in stackoverflow.
I am using VS Code (1.49.0)
.
I just noticed after I installed @material-ui/core
.
Honestly, I cannot say exactly when this happened.
I guess the cause is not @material-ui/core
but I don't know what causes this.
In addition to that, I don't know what effects it has to my project.
What does it mean? And what happens this strikethrough? Would you please teach me them?
Thank you very much.
Use the textDecoration property to strikethrough text in React, e.g. <span style={{textDecoration: 'line-through'}}> . The text-decoration CSS property sets the appearance of decorative lines on text. Copied!
Super(): It is used to call the constructor of its parent class. This is required when we need to access some variables of its parent class. Props: It is a special keyword that is used in react stands for properties. Used for passing data from one component to another.
Inline If with Logical && Operator It works because in JavaScript, true && expression always evaluates to expression , and false && expression always evaluates to false . Therefore, if the condition is true , the element right after && will appear in the output. If it is false , React will ignore and skip it.
ctx is a context object containing those properties (Source): pathname - path section of URL. query - query string section of URL parsed as an object. asPath - String of the actual path (including the query) shows in the browser. req - HTTP request object (server only)
It seems it is related to the new update of VS Code: https://code.visualstudio.com/updates/v1_49#_deprecated-tag-support-for-javascript-and-typescript
To fix the issue, for now, you can change super(props)
to super()
and it will fix it. It will not affect your codes if you are not using props
in the codes inside constructor()
, which means it will not affect your code since you have not used props inside constructor.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With