Here is my first front-end project and the first react project Random Quote Machine Live app,
GitHub repo
I’m new at using react.js, so I hope I’ll get great advice, comments, ideas, suggestions from your feed back so I can improve and do better in the next projects.
This is some good written code, but logic is bit off to my taste. 4 simple rules:
- if there’s an error while fetching - the only way to re-try is to reload page, because ‘New Quote’ button would do exactly nothing - no dead UI elements.
-
data should not be a state -
this.quotes
would be your cache andthis.state.quoteIndex
would store the index of your cache (you do not store data twice) to display
…and then you would have something like:setNewIndex(quotes.length, current)
withcurrent
to make sure you exclude currently shown quote - anything could happen
1 Like
Thanks @snigo for taking time to look at it, one of the things that I haven’t got well is how to manage well state of the app, but I’ll work on it and try to improve it.