при сабмите this.request(e.target) отрабатывает как нужно, но setState не срабатывает совсем.
handleSubmit = e => {
};this.setState({
currentState: {
...this.state.currentState,
submited: true,
},
});PS как я могу изменить состояние после возвращения request. В функции .then контекст this я получить не могу
this.request(e.target).then(() => {
this.setState({
currentState: {
...this.state.currentState,
submited: true
}
});
});handleSubmit = async e => {
e.preventDefault();
await this.request(e.target);
this.setState({
currentState: {
...this.state.currentState,
submited: true
}
});
};
Беру пример из офф документации...
Делал по этому примеру...
let iconRef;
const getIconRef = node => iconRef = node;
const IconsList = {
internet: (
<svg ref={getIconRef} width="22px" height="16px" viewBox="0 0 22 16" version="1.1">
/* ... */
</svg>
),
];copyToClipboard = text => {
var textField = document.createElement("textarea");
textField.innerText = iconRef;
document.body.appendChild(textField);
textField.select();
document.execCommand("copy");
textField.remove();
};import { renderToString } from 'react-dom/server';
textField.innerText = renderToString(/* иконка описанная JSX */); export default connect(mapStateToProps, null, null, { withRef: true })(Component);this.someRefName.getWrappedInstance();render метод наследуется от extends Component??
Почему мы не пишем this.render() ???
this.setState(prevState => {
prevState.fruitList.push("Мандаринка");
return {
fruitList: prevState.fruitList
};
});{type: 'CANGE_TRACK', tracks}} else if (action.type === 'CANGE_TRACK'){
return state;
}this.setState({});props.tracks.forEach(obj => {
if (obj.id === track.id){
obj.name = track.name;
}
});} else if (action.type === 'CANGE_TRACK'){
return [
...state,
action.payload,
];
}<div id="my-react-module-root"></div>
<script type="text/javascript" src="my-react-module-bundle.js"></script>import React from 'react';
import { render } from 'react-dom';
import MyReactModule from './MyReactModule';
render(
<MyReactModule />,
document.getElementById('my-react-module-root'),
); // without compose
withLog(withRouter(connect(mapStateToProps)(withDropdown(props)(Component))));
// with compose
compose(
withLog,
withRouter,
connect(mapStateToProps),
withDropdown(props),
)(Component);const foo = compose(...functions);