javascript - component gets re-rendered when using Higher Order Component -


i struggling use higher order component showing loader icon. when use higher order component , pass props(isrequesting flag) track if requesting flag true or false, requesting flag changes false true , continues forever. if don't use hoc, there won't re-render case.

i have attached screenshot here

enter image description here

here code loaderhoc

const loaderhoc = prop => wrappedcomponent => {   return class loaderhoc extends react.purecomponent {     render() {       console.log('prop', this.props[prop]);       return this.props[prop] ? <h1>loading...</h1> : <wrappedcomponent {...this.props} />;     }   }; };  export default loaderhoc;   @loaderhoc('isrequesting') class logs extends react.purecomponent {   constructor(props) {     super(props);     this.state = {       show: false,       open: false,       loading: true     };   }   componentdidmount() { // here component mounts , unmounts again , again     if (this.props.logs && object.keys(this.props.logs).length > 0) {       this.props.requestlogs();     }   }    handledialog = (key, logs) => {     this.setstate({ show: true });     const logsdetail = <logsdetail hidedialog={this.props.hidedialog} log={logs} />;     this.props.showdialog(logsdetail);   };    handledelete = key => {     this.setstate({ show: true });     const logdeleteconfirmation = (       <deleteconfirmation         hidedialog={this.props.hidedialog}         deletekey={key}         ondelete={this.props.deletelog}         text="log"       />     );     this.props.showdialog(logdeleteconfirmation);   };    render() {     const { logs, isrequesting } = this.props;     return (       <div classname="left container">         <ul classname="list-group">           <loglist             logs={logs}             handledelete={key => this.handledelete(key)}             handledialog={(key, errorstack) => this.handledialog(key, errorstack)}           />           {this.state.show ? this.props.dialog : null}         </ul>       </div>     );   } }  export default connect(mapstatetoprops, mapdispatchtoprops)(logs);   const loglist = ({ logs, ...props }) => {   return (     <div>       <reactcsstransitiongroup {...transitionoptions}>         {object.keys(logs).length > 0           ? logs.map(log =>               <div classname="segment" key={log._id}>                 <li classname="two columns grid">                   <div                     classname="column"                     onclick={() => props.handledialog(log._id, log.error_stack)}                   >                     <p>                       {log.error_message}                     </p>                   </div>                   <div classname="column align-right" onclick={() => props.handledelete(log._id)}>                     <a classname="negative icon button">                       <i classname="icon icon-trash" />{' '}                     </a>                   </div>                 </li>               </div>             )           : <p>no content load</p>}       </reactcsstransitiongroup>     </div>   ); }; 

i have posted code in detail in gist. here the link.

i struggling on hoc since week. couldn't find solution. expert on hoc can me, please?


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -