Answer the question
In order to leave comments, you need to log in
How to overwrite a functional component into a class one?
I had a functional component, but I need to replace it with a class one. I don't know how to pass props {children} now. I apologize for the possibly incorrect wording, I just started to study. I tried to write in constructor{}, nothing happened. I couldn't find anything on google other than this. Perhaps I phrased my question incorrectly.
const Layout = ({children}) => (
<div className='view-container'>
<div className='container'>
<div className='row'>
<div className='col-md-12'>
<Sidebar />
</div>
<div className='col-md-12'>
{children}
</div>
</div>
</div>
</div>
)
class Layout extends React.Component {
papermintRef = React.createRef();
componentDidMount() {
Peppermint(this.papermintRef.current);
}
componentDidUpdate() {
Peppermint(this.papermintRef.current);
}
shouldComponentUpdate() {
return false;
}
render() {
return(
<div className='view-container'>
<div className='container'>
<div ref={this.papermintRef} className="peppermint" id="peppermint">
<div className='col-md-12'>
<Sidebar />
</div>
<div className='col-md-12'>
{children}
</div>
</div>
</div>
</div>
);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question