<script type="text/babel">
var TeamCard = React.createClass({
render: function () {
return (
<article className="open hidden">
<img className="article-img" src={this.props.imagePath} alt={this.props.name} />
<h1 className="article-title">
<a href="">{this.props.name}</a>
</h1>
</article>
)
}
})
ReactDOM.render(
<div>
<TeamCard imagePath="svg/charlotte-hornets.svg" name="Charlotte Hornets"/>
<TeamCard imagePath="svg/charlotte-hornets.svg" name="Charlotte Hornets"/>
</div>,
document.getElementById("cards")
)
</script>
class UserEntity {
public name: number | string;
}
const itemList = products.map(item => item.category === "Category Two" && <ProductCard
key = {item.id}
title = {item.title}
category = {item.category}
/>)
let checkboxes= Object.assign({}, this.state.checkboxes); // Создаем копию, можно просто ссылку взять, но копию безопаснее
checkboxes[e.target.value] = false; // изменяем поле
this.setState({checkboxes}); // Сохраняем
this.setState({
checkboxes: {
...this.state.checkboxes,
[e.target.value]: false // измененное поле объекта checkboxes
}
})
ref={ this.input }
this.setState({
showForm: true
}, () => {
console.log(this.input);
});
getValueForInput() {
this.onHandleFetch(this.props.params.idValue); // передача id
console.log(this.state.data); // здесь не выводятся данные
return this.state.data.value; // тут тоже не получается значение, т.к. onHandleFetch его еще не успел подготовить
}
class Flight extends Component {
getWeekDay = (date) => {
//..
}
// ....
}
const newDate = new Date (year, month, day, );
const monthName = ["дек", "янв", "фев", "мар", "апр", "мая", "июня", "июля", "авг", "сент", "окт", "ноя", "дек"];
const newMonth = monthName[newDate.getMonth()];
const newDate = new Date(year, month - 1, day)
const getStopsNumber = (stop) =>{
switch (stop) {
case 3:
return "3 пересадки"
case 2:
return "2 пересадки"
case 1:
return "1 пересадка"
case 0:
return "без пересадок"
default:
return // это не нужно делать, писать return. Если вы удалите эту (и строку выше), то результат будет такой же - undefined
}
}
<input onClick={() => this.props.stopsClick("allStops")} />
<input onClick={() => this.props.stopsClick("noStops")} />
if( this.state.stops.allStops === false && this.state.stops.noStops === true && this.state.stops.oneStop === true && this.state.stops.twoStop === true && this.state.stops.threeStop === true ){
newStops = {...this.state.stops, allStops: true}
}
Хватит ли моих знаний для создания SPA?