DEV Community

Discussion on: 7 code smells in your React components

sfiquet profile image
Sylvie Fiquet • Edited on

Hi! I really enjoyed your article. The options pattern will help with a component of mine that didn't feel right.

I think the reducer example needs to be edited though:

  • the dispatch type for selectItem is 'reset', I believe it should be 'selectItem' to match the reducer?
  • shouldn't the case for selectItem do the same thing as the function? isOpen and inputValue won't change on their own. Or am I missing something?
    case "selectItem":
      return {
        isOpen: false,
        selectedItem: action.payload
Enter fullscreen mode Exit fullscreen mode
awnton profile image
Anton Gunnarsson Author

Thank you Sylvie and good catch! A bit too fast with the copy/paste it seems! :D Updated it now! 🙏