Answers for "reactjs refresh part of a component"

37

how to refresh the page using react

window.location.reload(false);
Posted by: Guest on February-24-2020
0

refresh a single component

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;
Posted by: Guest on March-01-2022

Code answers related to "reactjs refresh part of a component"

Code answers related to "Javascript"

Browse Popular Code Answers by Language