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
Post a Comment