![]() ![]() Let’s say we have a component that handles a user application to some organization:įunction Button ( īy using a reducer we’ve encapsulated the logic for managing our state and moved the complexity out of our component. ![]() Could I use composition?Ī pattern that is very good but often overlooked is to compose components instead of handling all logic inside just one. For example if the component has incompatible props or returns JSX from functions. Like functions, components should do one thing well so it’s always good to check if it’s possible to split the component into multiple smaller components. But when you do stumble upon a component that has many props or you get the urge to add just one more to the already long list of props there’s a couple of things to consider: Is this component doing multiple things? You might find yourself in a situation where a component have 20 props or more, and still be satisfied that it only does one thing. Passing too many props into a single component may be a sign that the component should be split up. What’s a code smell? A code smell is something that could indicate a deeper problem within a code base, but isn’t necessarily a bug. React component code smells □ This post is still growing and might be updated.Ī growing collection of code smells in React components.
0 Comments
Leave a Reply. |