A
A
Alfieros2019-05-15 19:26:07
React
Alfieros, 2019-05-15 19:26:07

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>
)

Here's what's at the moment
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

1 answer(s)
0
0xD34F, 2019-05-15
@mrsexy

{this.props.children}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question