reactjs - Update loginc for component with setState -


i read several posts on setstate batching updates , not being in sync, however, don't understand how component should update (in fact text in same container won't update)...

i have component (really glyph , text) should update when state changes - when user clicks on nav - (imitating checkbox since 1 doesn't work of "navitem")

    import react, { component } 'react';     import { glyphicon, nav, navbar, navitem, menuitem, navdropdown } 'react-bootstrap';      class app extends component {         constructor(props) {             super(props);              this.state = {                 isdevon: false             };            }          toggledevtools = (k,event) => {             event.preventdefault();             this.setstate({                  isdevon : !this.state.isdevon,             });         }          render() {             <div classname="app container">                 <navbar.collapse>                     <nav>                         <input type='text' value={this.state.isdevon}/>                         <navitem key={'toggledevtools'} onselect={this.toggledevtools}>                             <glyphicon glyph={this.state.isdevon?"check":"unchecked"} classname="checkmark" />                             {this.state.isdevon?"disable tools":"enable tools"}                         </navitem>                     </nav>                 </navbar.collapse>             </div>         }     } 

however, when toggling state, rendered 1 step behind, , don't understand why calling render begin when still in old state since hasn't been update, , after updated don't render call @ all......

(code has logic check mark , text revesed because behind )


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 -