onMarkClick = (e) => {
e.stopPropagation();
this.setState({
important: true,
});
};
return (
<span>
<span
className={classNames}
onClick={this.onLabelClick}
>
{label}
</span>
<button type="button" onClick= {this.onMarkClick}>
<i className="fa fa-exclamation"/>
</button>
</span>
);
.todo-list-item.done {
text-decoration : line-through;
}
Что бы Вы изменили в коде?
const uid = () => Math.random().toString(36).slice(2);
class App extends React.Component {
state = {
tasks: [
{
id: uid(),
title: 'title',
description: 'description',
}
]
};
handleCreateTaskClick = () => {
this.setState(state => ({
tasks: [
...state.tasks,
{
id: uid(),
title: 'title',
description: 'description',
},
],
}));
};
render() {
const { tasks } = this.state;
return (
<div>
<button onClick={this.handleCreateTaskClick}>Добавить задачу</button>
<ul>
{tasks.map(task => (
<li key={task.id}>
id: {task.id} | {task.title} | {task.description}
</li>
))}
</ul>
</div>
);
}
}
yarn add react-redux
устанавливает стабильную, рекомендованную к использованию версию пакета.<script crossorigin src="https://unpkg.com/react@16/umd/react.production.min.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"></script>
import React, { useContext } from 'react';
test: /\.(js|jsx)$/,
exclude: /node_modules\/(?!(trouble-package-name|other-thouble-package-name)\/).*/,
import React from 'react';
import { render } from 'react-dom';
import { BrowserRouter } from 'react-router-dom';
import App from './App';
render(
<BrowserRouter>
<App />
</BrowserRouter>,
document.getElementById('root'),
);
import React from 'react';
import { render } from 'react-dom';
import { Router } from 'react-router';
import { createBrowserHistory } from 'history';
import App from './App';
const history = createBrowserHistory();
render(
<Router history={history}>
<App />
</Router>,
document.getElementById('root'),
);
render() {
const { value } = this.state;
return (
<>
<Child1 value={value} />
<Child2 value={value} />
<Child3 />
</>
);
}
componentDidUpdate(prevProps) {
if (prevProps.value !== this.props.value) {
this.doSomething();
}
}
this.setState({ scale: 'c', temperature });
this.setState({ scale: 'c', temperature: temperature });
render() {
const { playList, slug } = this.props;
const index = playList.findIndex(i => i.slug === slug);
const video = playList[index];
const prev = playList[index - 1];
const next = playList[index + 1];
render(
<div>
{/* ... */}
<div>
{prev && <Link to={`/video/${prev.slug}`}>Prev</Link>}
{next && <Link to={`/video/${next.slug}`}>Next</Link>}
</div>
<div/>
);
}