Обновить один компонент
import React from "react";
class App extends React.Component {
handleRefresh = () => {
// by calling this method react re-renders the component
this.setState({});
};
render() {
return (
<div>
<h1>{Math.random()}</h1>
<button onClick={this.handleRefresh}>Refresh component</button>
</div>
);
}
}
export default App;
Fran carlos Castillo robles