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
-
Tried only defining new quote function and invoking it inside the render method
-
Tried defining both the new quote function and componentdid update function in the same line using commas(how to do that?)
-
Tried defining newquote function inside the componentdidupdate method and immediately invoking it.
-
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)