I have an object with the property home.ready = false. When the object is done getting data, cleaning it etc it changes to home.ready= true.
I need my component to register the change and update. My component:
class HomeNav extends React.Component { render() { let data = this.props.data; let uniqueTabs = _.uniq(_.map(data, x => x.tab)).sort(); let tabs = uniqueTabs.map((tab, index) => { let itemsByTab = _.filter(data, (x => x.tab == tab)); return <Tabs key={tab} tab={tab} index={index} data={itemsByTab} />; }); console.log(this.props) return ( <section> <div className="wb-tabs"> <div className="tabpanels"> { this.props.ready ? {tabs} : <p>Loading...</p> } </div> </div> </section> ) } }; ReactDOM.render( <HomeNav data={home.data.nav} ready={home.ready}/>, document.getElementById('home-nav') ); This is the home object. It's a simple object that gets data and once the data is ready the property ready changes from false to true. I can't get React to recognize that change. And at times React will say home is undefined.
readyas a prop to your component it should update automatically if its value changed. It should be your container component that gets the data and set thehome.readywhich then passes it down toHomeNav.home. Include the code that passes theprop!homeis an object in another script. The default value of home.ready isfalseand when my data is retrieved it's changed totrue. This is the home object is you want to see it: github.com/simkessy/sharepoint-projects/blob/master/…