jQuery UI Widgets Forums React Modularize Code in React

Tagged: 

This topic contains 3 replies, has 4 voices, and was last updated by  Krood 9 months, 2 weeks ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • Modularize Code in React #113427

    Ankitdixit
    Participant

    Hello Everyone, Can anyone suggest me below sample is right to modularize code in React, export and import properties? I am preparing for my upcoming react interview, So your suggestions are very helpful to me.

    export default class ChildComponent extends React.Component {
    render() {
    return(
    This is a child component
    );
    }
    }
    import ChildComponent from ‘./childcomponent.js’;
    class ParentComponent extends React.Component {
    render() {
    return(
    );
    }
    }

    Modularize Code in React #113453

    Martin
    Participant

    Hello Ankitdixit,

    Yes, that is right.
    After you have imported the ChildComponent you can use it inside the parent component like this, for example:

    import ChildComponent from ‘./childcomponent.js’;
    class ParentComponent extends React.Component {
      render() {
        return(
           <div>
               <ChildComponent /> 
           </div>
        );
     }
    }

    Best Regards,
    Martin Yotov

    jQWidgets team
    https://www.jqwidgets.com

    Modularize Code in React #113734

    singhjyoti0894
    Participant

    Yes, the given sample code is correct.

    You can also verify from this post.

    Modularize Code in React #114214

    Krood
    Participant

    Thank you for this!

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.