Random Quote Machine I have some repeated code, how can I reduce it?

I just completed my Random Quote Machine. But I have written a lot of repeated code that is in the component did mount and new quote functions. How can I combine them into one. Tried a lot kind of frustrated like

  1. Tried only defining new quote function and invoking it inside the render method

  2. Tried defining both the new quote function and componentdid update function in the same line using commas(how to do that?)

  3. Tried defining newquote function inside the componentdidupdate method and immediately invoking it.

  4. Tried calling componentdid update method on the onclick event in the button(can we do it?)

How to do it guys and how can I do the above things would love to know.

(I have not put the css now and will put later on)

Have you tried calling new quote function from inside of componentdidmount?

1 Like

Yes I had done that it kept saying object error

It works using this, thank you!


This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.