Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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;
Source by reactgo.com #
 
PREVIOUS NEXT
Tagged: #refresh #single #component
ADD COMMENT
Topic
Name
2+6 =