create-react-app-with-redux icon indicating copy to clipboard operation
create-react-app-with-redux copied to clipboard

some code issues

Open pazams opened this issue 9 years ago • 1 comments

Awesome stuff, thanks for this repo!

I found some code issues I would like to raise:

  1. No need for component state. Safe to delete these lines https://github.com/tstringer/create-react-app-with-redux/blob/master/src/components/PeopleContainer.js#L12-L14

    this.state = {
        people: []
    };
    
  2. person.lastname is not a safe key since cannot guarantee uniqueness https://github.com/tstringer/create-react-app-with-redux/blob/master/src/components/PeopleList.js#L8 <Person key={person.lastname} person={person} />

  3. Avoid using the document object (getElementById). https://github.com/tstringer/create-react-app-with-redux/blob/master/src/components/PersonInput.js#L11 const firstNameElement = document.getElementById('firstname');

For the last issue, consider refs, or even better- no refs at all and just more props < ... focus={isFocused} >

pazams avatar Oct 26 '16 18:10 pazams

Really great information! And totally agreed with these.

Thanks!

trstringer avatar Oct 27 '16 12:10 trstringer