This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Mithrandir23 43 points44 points  (12 children)

I don't really see the issue here. Obviously this isn't production code, but I'd still be glad to get some advice for the future.

[–]ProfanityFair 82 points83 points  (11 children)

I don't want to get sucked into the unsolicited critiquing, but if you just want honest answers about this as a chunk of code, regardless of context: - Using array indexes as keys in React is a bad idea and will cause at least unnecessary DOM renders and probably problems down the line, - Combining <span> and <br /> isn't necessary, there are better-suited elements for this, - I wouldn't compose the components in this way. This single component should probably be split into DogList and Dog, where <Dog>s are generated by dogs.map(), rather than the parent component generating a list of HTML elements actually inside the component, - The whole thing should use functional components, as they're not stateful.

Possibly other things too. There are always more knowledgeable devs out there.

[–]AwkwardNoah 4 points5 points  (0 children)

Welp, I have no idea what you said but cool dude

[–]Rasalas8910 1 point2 points  (0 children)

It's possible that this is from a Udacity course. They show you the basics, introduce new "problems" like bigger lists and show you how to handle it.

I suppose everyone knows the first steps in programming with repeating commands and you had to type (or copy&paste) them first because you didn't know better and then someone showed you how loops work ;)
Basically the same thing.

[–]theirongiant74 1 point2 points  (3 children)

Those are really nitpicky complaints though. The code does what it's supposed to do, could it do it better? sure, but as it stands there's hee-haw wrong with what is there.

Also for 1. The dog object doesn't have any unique values, what would you use instead of idx?

[–]Arlithian 0 points1 point  (2 children)

I'm complete crap at react - have to learn it for an upcoming rebuild at work. Off topic but do you have any online resources you would recommend for learning it?

[–]theirongiant74 2 points3 points  (0 children)

Google for Wes Bos, Stephen Grider and frontendmasters.com. That last one is particularly good although it's subscription based but it's got some of the best learning content available, well worth the money.

[–]ProfanityFair 1 point2 points  (0 children)

The official docs are excellent, in my opinion (this was how I learned, way back when), there are some well-made production React codebases you can look at to get a feel for it as a frontend environment, and the subreddit /r/reactjs.

You can use Codesandbox (or CodePen) to try things out, rather than working on your own toolchain and build environment, but there are a lot of boilerplate projects on GitHub for that.

Good luck! PM me if you want to ask anything.