Passing a component to the useState() hook

I’m trying to make a system where my App component’s state stores another component, which it will render. Any component should be able to update this state, forcing the App component to re-render.

function Page1() {
    return <p>Hello world!</p>
}

export default function App() {

    let [Page, setPage] = useState(Page1);

    return (
        <div id="app">
            <Page/>
        </div>
    );
}

I know how to make the state accessible by any component, but I’m having some issues with rendering the component in App’s state. When I try running the code above, I get the following error:

Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.

Strangely enough, making the state a JSON object seems to fix the issue:

let [Page, setPage] = useState({Page: Page1});

    return (
        <div id="app">
            <Page.Page/>
        </div>
    );

But I was wondering if there was a way to do this without the JSON. It seems to work fine with numbers and strings; what’s different about components?

1,429 thoughts on “Passing a component to the useState() hook”

  1. Its like you read my thoughts! You appear to understand a lot about this,
    like you wrote the ebook in it or something. I believe that you could do
    with a few percent to force the message house a little bit, however instead of that,
    that is excellent blog. A fantastic read.
    I will certainly be back.

    Reply
  2. Pingback: cialis for women
  3. [url=https://hotviagraonline.com/]generic viagra over the counter usa[/url] [url=https://ivermectiner.com/]stromectol tablets[/url] [url=https://viagragenpill.com/]order viagra online usa[/url] [url=https://gettadalafil.com/]buy tadalafil online canada[/url] [url=https://ordercialispills.com/]can you buy cialis online from canada[/url]

    Reply
  4. It’s the best time to make some plans for the
    future and it is time to be happy. I’ve read this submit and if I may I desire to recommend you few interesting issues
    or suggestions. Maybe you could write next articles regarding
    this article. I want to learn even more things approximately it!

    Reply
  5. I have been browsing online more than 3 hours today,
    but I by no means discovered any interesting article like yours.
    It is beautiful value sufficient for me. In my view,
    if all web owners and bloggers made just right content as you did, the net will
    probably be a lot more helpful than ever before.

    Reply
  6. [url=https://ivermectinpillscv.com/]buy ivermectin nz[/url] [url=https://sildenafilgenericpills.com/]sildenafil online europe[/url] [url=https://norxtadalafil.com/]tadalafil tablets[/url] [url=https://modafinilxc.com/]buy modafinil usa online[/url] [url=https://gettadalafil.com/]tadalafil tablets[/url]

    Reply
  7. It’s perfect time to make a few plans for the longer term and it’s time to be happy.
    I have learn this publish and if I may just I want to suggest you few
    attention-grabbing issues or advice. Maybe you could write subsequent articles referring
    to this article. I wish to learn even more things about it!

    Reply
  8. [url=http://tadalafilab.com/]canadian online pharmacy tadalafil[/url] [url=http://ivermectincvpill.com/]ivermectin ireland[/url] [url=http://cialisrf.com/]cialis india online[/url] [url=http://cialisvtab.com/]cheap cialis 5mg australia[/url] [url=http://modafinilxc.com/]modafinil paypal uk[/url]

    Reply
  9. [url=https://cialisfm.com/]cialis generic in usa[/url] [url=https://tadalafileff.com/]tadalafil for sale canada[/url] [url=https://ivermectincvpill.com/]stromectol 3 mg[/url] [url=https://sildenafilgenericpills.com/]generic sildenafil no prescription[/url] [url=https://buycialist.com/]buy daily cialis[/url] [url=https://cialisur.com/]buy cheap cialis[/url] [url=https://pharmacyrite.com/]canadian pharmacy uk delivery[/url] [url=https://cialisqtab.com/]online medication cialis[/url]

    Reply
  10. [url=https://ebcialis.com/]cheapest tadalafil cost in usa[/url] [url=https://pharmacyrite.com/]reputable indian pharmacies[/url] [url=https://cleocinmed.com/]where can i buy clindamycin without a prescription[/url] [url=https://prednisolonesale.com/]generic prednisolone[/url] [url=https://ivermectinnew.com/]stromectol 3 mg price[/url] [url=https://ivermectinpillscv.com/]stromectol canada[/url] [url=https://hydroxychloroquinetb.com/]quineprox 400[/url] [url=https://extratadalafil.com/]india tadalafil capsule cheap[/url] [url=https://ivermectiner.com/]stromectol tablets uk[/url] [url=https://rpipharm.com/]combivent cheap[/url]

    Reply
  11. [url=http://ivermectinnew.com/]stromectol tablets[/url] [url=http://pharmacysx.com/]cheapest pharmacy to get prescriptions filled[/url] [url=http://modafinilxc.com/]25mg modafinil[/url] [url=http://cicialis.com/]buy cialis online with paypal[/url]

    Reply
  12. [url=https://ebcialis.com/]cialis tabs[/url] [url=https://ivermectinmt.com/]how much is ivermectin[/url] [url=https://sildenafilsale.com/]online sildenafil usa[/url] [url=https://buycialist.com/]cialis from singapore[/url] [url=https://sildenafilhot.com/]80 mg sildenafil[/url] [url=https://buyviagramed.com/]viagra miami[/url] [url=https://buyingsildenafil.com/]sildenafil generic costs[/url] [url=https://cleocinmed.com/]order clindamycin gel[/url] [url=https://pharmacysx.com/]discount pharmacy mexico[/url] [url=https://onlinenorx.com/]hydroxychloroquine sulfate[/url]

    Reply
  13. [url=https://longpills.com/]buy cephalexin from mexico[/url] [url=https://tadalafilcost.com/]tadalafil 40 mg online india[/url] [url=https://cialisfb.com/]cialis 5mg pharmacy[/url] [url=https://pharmacyrite.com/]top online pharmacy 247[/url] [url=https://gettadalafil.com/]tadalafil 20 mg price canada[/url] [url=https://cialisrf.com/]where to purchase cialis[/url] [url=https://ppcialis.com/]cialis for daily use 5 mg cost[/url] [url=https://hotviagraonline.com/]viagra mexico[/url] [url=https://modafinilxc.com/]modafinil for sale us[/url] [url=https://tadalafileff.com/]generic tadalafil online 20mg buy[/url]

    Reply
  14. I have been surfing online more than 3 hours these days, yet I by no means
    discovered any fascinating article like yours. It’s beautiful price sufficient for me.
    In my view, if all site owners and bloggers made just right content as you did, the web will probably be much more helpful than ever before.

    Reply
  15. It’s the best time to make some plans for the future and it’s time to be happy.
    I have read this post and if I could I want to suggest you
    few interesting things or tips. Maybe you could write next articles referring to this article.
    I wish to read more things about it!

    Reply
  16. Hi there would you mind sharing which blog platform you’re working with?
    I’m going to start my own blog in the near future but I’m having a hard time deciding between BlogEngine/Wordpress/B2evolution and Drupal.
    The reason I ask is because your layout seems different then most blogs and I’m
    looking for something unique. P.S Sorry for getting off-topic but I had to ask!

    Reply
  17. [url=http://extratadalafil.com/]cheap tadalafil 5 mg[/url] [url=http://modafinilasap.com/]modafinil uk prescription[/url] [url=http://buycialismed.com/]discount canadian pharmacy cialis[/url]

    Reply
  18. I’ll right away snatch your rss feed as I can not to find
    your e-mail subscription link or e-newsletter service. Do you have any?
    Please permit me recognise so that I may subscribe. Thanks.

    Reply
  19. I have been surfing on-line more than 3 hours nowadays, but I never discovered any interesting article
    like yours. It’s pretty price enough for me. In my opinion, if all web owners and
    bloggers made excellent content as you probably did,
    the internet will be much more helpful than ever before.

    Reply
  20. It’s appropriate time to make a few plans for the longer term and it is
    time to be happy. I’ve read this publish and if I may just I desire to suggest you few attention-grabbing things or
    suggestions. Maybe you could write next articles relating to this article.
    I wish to read more issues about it!

    Reply
  21. I have been surfing online more than 2 hours today, yet I never found any interesting article like yours.
    It is pretty worth enough for me. In my opinion, if all web owners
    and bloggers made good content as you did, the net will be a lot more useful than ever before.

    Reply
  22. [url=https://pharmacyzeus.com/]reputable online pharmacy reddit[/url] [url=https://cialisextr.com/]can you order cialis online[/url] [url=https://pharmacylewis.com/]canadian pharmacies not requiring prescription[/url] [url=https://thebestviagra.com/]us online pharmacy viagra[/url]

    Reply
  23. It is appropriate time to make some plans for the future and
    it is time to be happy. I have read this post and if I could I desire to suggest you few interesting things or tips.

    Maybe you can write next articles referring to this article.
    I want to read even more things about it!

    Reply
  24. I’ll immediately seize your rss feed as I can’t find your e-mail
    subscription link or e-newsletter service. Do you have any?
    Please allow me know in order that I may subscribe.
    Thanks.

    Reply
  25. [url=https://phdtabs.com/]generic finasteride nz[/url] [url=https://onlinemediorder.com/]provigil south africa[/url] [url=https://startpills.com/]zestril 10 mg price[/url] [url=https://buyrxtablets.com/]clomid 100 mg[/url] [url=https://cialisgenericnow.com/]cialis discount pharmacy[/url] [url=https://ordertadalafilpills.com/]compare cialis prices[/url] [url=https://ivermectinp.com/]stromectol over the counter[/url] [url=https://pviagra.com/]viagra without prescription uk[/url] [url=https://xrpills.com/]roaccutane 20mg[/url] [url=https://sildenafilchem.com/]how to get sildenafil prescription[/url]

    Reply
  26. Oh my goodness! Awesome article dude! Thank you, However I am going through problems with your RSS.
    I don’t understand why I can’t join it. Is there anybody having similar RSS issues?
    Anyone who knows the answer will you kindly respond?
    Thanx!!

    Reply
  27. I will right away take hold of your rss as I can’t find your e-mail subscription link or newsletter service.

    Do you have any? Kindly allow me realize so that I may
    just subscribe. Thanks.

    Reply
  28. Its like you learn my mind! You appear to know a lot about this,
    such as you wrote the e-book in it or something. I believe that
    you just can do with some % to pressure the message home
    a little bit, however instead of that, this is fantastic blog.
    A fantastic read. I will certainly be back.

    Reply
  29. Heya i am for the primary time here. I came across this board and I find It truly useful & it helped me out much. I hope to provide something again and help others like you helped me.

    Reply
  30. It’s appropriate time to make some plans for
    the future and it’s time to be happy. I have read this post and if I could I desire
    to suggest you few interesting things or tips. Maybe you could write next articles referring to this article.
    I wish to read even more things about it!

    Reply
  31. I’ve been browsing on-line more than 3 hours nowadays, but I
    by no means found any interesting article like yours.
    It’s pretty worth sufficient for me. In my opinion, if all
    website owners and bloggers made excellent content material as you probably did, the internet will likely be much more useful than ever before.

    Reply
  32. It’s appropriate time to make a few plans for the future
    and it’s time to be happy. I have read this put up
    and if I may just I desire to suggest you some
    interesting issues or advice. Maybe you could write subsequent articles relating to this article.
    I wish to learn more issues approximately it!

    Reply
  33. It’s the best time to make some plans for the future and it’s time to
    be happy. I’ve read this post and if I could
    I want to suggest you some interesting things or tips.
    Maybe you could write next articles referring to this article.
    I desire to read even more things about it!

    Reply
  34. [url=https://tadalafilmtab.com/]tadalafil 10 mg canadian pharmacy[/url] [url=https://cialisextr.com/]cialis 40 mg online[/url] [url=https://viagrabi.com/]canadian drug pharmacy viagra[/url] [url=https://pviagra.com/]viagra 50mg price[/url] [url=https://incrhealth.com/]disulfiram for sale[/url] [url=https://sildenafilmedicine.com/]where can you get female viagra pills[/url] [url=https://viagrawithnoprescription.com/]viagra singapore over the counter[/url] [url=https://viagrauni.com/]sildenafil soft 100mg[/url] [url=https://anviagra.com/]buy genuine viagra online canada[/url] [url=https://viagrafmed.com/]canadian pharmacy for viagra[/url]

    Reply
  35. [url=https://sildenafileasy.com/]how much is sildenafil 25 mg[/url] [url=https://viagracpill.com/]how to get sildenafil cheapest[/url] [url=https://wbapharmacy.com/]pharmacy prices[/url] [url=https://cialisfmed.com/]cialis canada online pharmacy[/url] [url=https://sildenafilvtab.com/]purchase viagra over the counter[/url]

    Reply
  36. [url=https://viagrasm.com/]viagra 15 mg[/url] [url=https://sildenafilpharm.com/]viagra 150 mg[/url] [url=https://buyrxtablets.com/]clomid generic price[/url] [url=https://cialisexpress.com/]canadian pharmacy cialis daily use[/url] [url=https://azcialis.com/]cheap generic cialis for sale[/url] [url=https://cialisconnect.com/]best canadian online pharmacy cialis[/url] [url=https://tadalafillowprice.com/]tadalafil 20mg for sale[/url] [url=https://eccpharm.com/]how to get prednisone online[/url] [url=https://pviagra.com/]buying viagra over the counter in usa[/url] [url=https://cialisextr.com/]best cialis[/url]

    Reply
  37. [url=https://pharmacylewis.com/]super saver pharmacy[/url] [url=https://xrpills.com/]where to get accutane online[/url] [url=https://dwpills.com/]lexapro[/url] [url=https://ivermectinzt.com/]cheap stromectol[/url] [url=https://cialisdf.com/]online cialis from india[/url] [url=https://onlinemediorder.com/]order modafinil canada[/url] [url=https://wbapharmacy.com/]rx pharmacy online[/url] [url=https://sildenafilmedicine.com/]100mg sildenafil 1 pill[/url]

    Reply
  38. I have been surfing online more than three hours today, yet I never found any interesting article like yours.

    It’s pretty worth enough for me. Personally, if all website
    owners and bloggers made good content as you did,
    the net will be much more useful than ever before.

    Reply
  39. Thanks for the something totally new you have unveiled in your post. One thing I want to reply to is that FSBO interactions are built over time. By bringing out yourself to owners the first weekend break their FSBO is actually announced, prior to the masses start out calling on Monday, you make a good link. By giving them resources, educational supplies, free reports, and forms, you become a good ally. If you take a personal fascination with them as well as their situation, you make a solid connection that, on most occasions, pays off if the owners opt with an agent they know and also trust – preferably you.

    Reply
  40. Nice blog right here! Additionally your website so much up very fast! What web host are you the usage of? Can I am getting your affiliate hyperlink to your host? I wish my site loaded up as quickly as yours lol.

    Reply
  41. Woah! I’m really digging the template/theme of this website.
    It’s simple, yet effective. A lot of times it’s hard to get that “perfect balance” between user friendliness and visual appearance.

    I must say you’ve done a fantastic job with this.
    Also, the blog loads super quick for me on Chrome. Outstanding Blog!

    Reply
  42. Howdy would you mind sharing which blog platform you’re
    working with? I’m going to start my own blog soon but I’m having a tough time selecting between BlogEngine/Wordpress/B2evolution and Drupal.
    The reason I ask is because your design and style seems different then most blogs and I’m looking for something
    unique. P.S Apologies for being off-topic but I had to
    ask! http://cleckleyfloors.com/

    Reply
  43. Pingback: all about viagra
  44. Good day! I could have sworn I’ve been to this site before but after browsing through
    some of the articles I realized it’s new to me.

    Nonetheless, I’m certainly pleased I found it and I’ll be bookmarking
    it and checking back regularly!

    Reply
  45. This is very interesting, You are a very skilled blogger.
    I have joined your feed and look forward to seeking more of your excellent
    post. Also, I’ve shared your site in my social networks!

    Reply
  46. Pingback: keto diet chart
  47. Magnificent items from you, man. I’ve take into
    account your stuff previous to and you’re just extremely excellent.
    I actually like what you’ve got here, certainly like what you’re stating and the best way through which
    you say it. You make it enjoyable and you continue to take care of to keep
    it wise. I can not wait to learn much more from you.
    This is actually a terrific web site.

    Reply