Do I have to use a constructor when importing an external module I made in React?What is the difference between using constructor vs getInitialState in React / React Native?Why do we need middleware for async flow in Redux?React functional stateless component, PureComponent, Component; what are the differences and when should we use what?Extending React component which is imported from a NPM module (typescript)have an error when i try import my component in react nativeConstructor(props) and super(props) VS constructor() and super() in ReactImporting pg in react-native codeIssue importing external modules from component included with react-loadableModalFilterPicker load more on scrollError: The following params are required: Client ID, Client Secret on clarifai api on React

Would all these three things have the exact same effect on the flight duration of a glider?

Isolated audio without a transformer

What does "see" in "the Holy See" mean?

How do I explain an exponentially complex intuitively?

May a man marry the women with whom he committed adultery?

Request for a Latin phrase as motto "God is highest/supreme"

Why is it considered Acid Rain with pH <5.6

If a 2019 UA artificer has the Repeating Shot infusion on two hand crossbows, can they use two-weapon fighting?

Please explain joy and/or the Kimatthiyasutta

How to judge a Ph.D. applicant that arrives "out of thin air"

Decreasing star size

Why was Sauron preparing for war instead of trying to find the ring?

Is there a wealth gap in Boston where the median net worth of white households is $247,500 while the median net worth for black families was $8?

The Sword in the Stone

How did Mysterio have these drones?

Am I allowed to use personal conversation as a source?

Commercial jet accompanied by small plane near Seattle

Assuring luggage isn't lost with short layover

How to store my pliers and wire cutters on my desk?

Japanese reading of an integer

Correlation length anisotropy in the 2D Ising model

Is it legal to use cash pulled from a credit card to pay the monthly payment on that credit card?

How to apply the changes to my `.zshrc` file after edit?

What to do when you reach a conclusion and find out later on that someone else already did?



Do I have to use a constructor when importing an external module I made in React?


What is the difference between using constructor vs getInitialState in React / React Native?Why do we need middleware for async flow in Redux?React functional stateless component, PureComponent, Component; what are the differences and when should we use what?Extending React component which is imported from a NPM module (typescript)have an error when i try import my component in react nativeConstructor(props) and super(props) VS constructor() and super() in ReactImporting pg in react-native codeIssue importing external modules from component included with react-loadableModalFilterPicker load more on scrollError: The following params are required: Client ID, Client Secret on clarifai api on React






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I made a module in react.
So, I imported the module. And then, the function of the external module was called using the constructor.



import connect from './api';
...

class App extends Component
constructor(props)
super(props);

connect(message =>
console.log(message);
);


render()
...




But I would like to express class fields syntax without using a constructor.



import connect from './api';
...

class App extends Component

connect(message =>
console.log(message);
);

render()
...




The results of the above code, 'connect' function is not executed because 'connect' is not declared.



Can't I get an function of external module without a constructor?










share|improve this question






















  • Give a look to the React life cycle component tutorialspoint.com/reactjs/reactjs_component_life_cycle.htm

    – julian salas
    Mar 26 at 19:05

















0















I made a module in react.
So, I imported the module. And then, the function of the external module was called using the constructor.



import connect from './api';
...

class App extends Component
constructor(props)
super(props);

connect(message =>
console.log(message);
);


render()
...




But I would like to express class fields syntax without using a constructor.



import connect from './api';
...

class App extends Component

connect(message =>
console.log(message);
);

render()
...




The results of the above code, 'connect' function is not executed because 'connect' is not declared.



Can't I get an function of external module without a constructor?










share|improve this question






















  • Give a look to the React life cycle component tutorialspoint.com/reactjs/reactjs_component_life_cycle.htm

    – julian salas
    Mar 26 at 19:05













0












0








0








I made a module in react.
So, I imported the module. And then, the function of the external module was called using the constructor.



import connect from './api';
...

class App extends Component
constructor(props)
super(props);

connect(message =>
console.log(message);
);


render()
...




But I would like to express class fields syntax without using a constructor.



import connect from './api';
...

class App extends Component

connect(message =>
console.log(message);
);

render()
...




The results of the above code, 'connect' function is not executed because 'connect' is not declared.



Can't I get an function of external module without a constructor?










share|improve this question














I made a module in react.
So, I imported the module. And then, the function of the external module was called using the constructor.



import connect from './api';
...

class App extends Component
constructor(props)
super(props);

connect(message =>
console.log(message);
);


render()
...




But I would like to express class fields syntax without using a constructor.



import connect from './api';
...

class App extends Component

connect(message =>
console.log(message);
);

render()
...




The results of the above code, 'connect' function is not executed because 'connect' is not declared.



Can't I get an function of external module without a constructor?







reactjs






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 26 at 18:48









SophiaSophia

726 bronze badges




726 bronze badges












  • Give a look to the React life cycle component tutorialspoint.com/reactjs/reactjs_component_life_cycle.htm

    – julian salas
    Mar 26 at 19:05

















  • Give a look to the React life cycle component tutorialspoint.com/reactjs/reactjs_component_life_cycle.htm

    – julian salas
    Mar 26 at 19:05
















Give a look to the React life cycle component tutorialspoint.com/reactjs/reactjs_component_life_cycle.htm

– julian salas
Mar 26 at 19:05





Give a look to the React life cycle component tutorialspoint.com/reactjs/reactjs_component_life_cycle.htm

– julian salas
Mar 26 at 19:05












1 Answer
1






active

oldest

votes


















1














Here is your connect.js:



export const connect = message => 
console.log(message);
;


Here is your component:



import React from 'react';

import connect from './connect';

class App extends React.Component

componentDidMount()
connect('connected');


render()
return (
<div>
<h1>Some Text...</h1>
</div>
);



export default App;


Should be fairly clear... If you have a question ask...






share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55364316%2fdo-i-have-to-use-a-constructor-when-importing-an-external-module-i-made-in-react%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    Here is your connect.js:



    export const connect = message => 
    console.log(message);
    ;


    Here is your component:



    import React from 'react';

    import connect from './connect';

    class App extends React.Component

    componentDidMount()
    connect('connected');


    render()
    return (
    <div>
    <h1>Some Text...</h1>
    </div>
    );



    export default App;


    Should be fairly clear... If you have a question ask...






    share|improve this answer



























      1














      Here is your connect.js:



      export const connect = message => 
      console.log(message);
      ;


      Here is your component:



      import React from 'react';

      import connect from './connect';

      class App extends React.Component

      componentDidMount()
      connect('connected');


      render()
      return (
      <div>
      <h1>Some Text...</h1>
      </div>
      );



      export default App;


      Should be fairly clear... If you have a question ask...






      share|improve this answer

























        1












        1








        1







        Here is your connect.js:



        export const connect = message => 
        console.log(message);
        ;


        Here is your component:



        import React from 'react';

        import connect from './connect';

        class App extends React.Component

        componentDidMount()
        connect('connected');


        render()
        return (
        <div>
        <h1>Some Text...</h1>
        </div>
        );



        export default App;


        Should be fairly clear... If you have a question ask...






        share|improve this answer













        Here is your connect.js:



        export const connect = message => 
        console.log(message);
        ;


        Here is your component:



        import React from 'react';

        import connect from './connect';

        class App extends React.Component

        componentDidMount()
        connect('connected');


        render()
        return (
        <div>
        <h1>Some Text...</h1>
        </div>
        );



        export default App;


        Should be fairly clear... If you have a question ask...







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 26 at 19:03









        SakoBuSakoBu

        2,1286 silver badges22 bronze badges




        2,1286 silver badges22 bronze badges


















            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55364316%2fdo-i-have-to-use-a-constructor-when-importing-an-external-module-i-made-in-react%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현