reactjs - Converting arrow function to React.Component with children -


i making blog in gatsby.js , have problem converting

const templatewrapper = ({children}) => ( <div>   <helmet     title="my website"     meta={[       { name: 'description', content: 'a brief history of myself' },       { name: 'keywords', content: 'myself, cv' },     ]}   />   <header />   <div>     {children()}   </div>   <footer/> </div>) 

to normal function. tried creating react.component class seems not children. aim make loading screen bar , thats why want convert it. tried this

class wrapper extends react.component {    constructor(props){     super(props);     this.state = {       loading: true     };   }   componentdidmount(){     settimeout(() => this.setstate({ loading: false }), 2500);    }   render(){     const { loading } = this.state;     if(loading){       return <loader/>     }     return(       <templatewrapper/>     );   } } 

and exported wrapper.. doesnt seem work, says children not function , stucks on loading icon (loader). ways solve this?

note. when export default templatewrapper works perfectly!


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 -