The difference is "presentational" and "container" components, also called smart and dumb components previously. The container component is the one that you "connect" and the presentation component is the one that just receives props.
I'll link out to this Medium article by Dan Abramov, the creator of redux.
To quote out the benefits section:
- Better separation of concerns. You understand your app and your UI better by writing components this way.
- Better reusability. You can use the same presentational component with completely different state sources, and turn those into separate container components that can be further reused.
- Presentational components are essentially your app’s “palette”. You can put them on a single page and let the designer tweak all their variations without touching the app’s logic. You can run screenshot regression tests on that page.
- This forces you to extract “layout components” such as Sidebar, Page, ContextMenu and use this.props.children instead of duplicating the same markup and layout in several container components.
In my personal experience, forcing myself to use this style does keep my components more "sane" and easier to understand/maintain. You are welcome to not use this style, but when you run into issues you might need to refactor to use this method that better separates concerns.
If I were to summarize without Dan's help, I'd say this: connecting all over the place makes it confusing as to where each prop that you have in your component comes from. If you force yourself to only connect at very specific places (in my projects, I tend to connect at the page level, and the root level), then you'll always know where things come from which helps debugging when things go wrong.
- Why to pass callbacks in React component's props instead of using react-redux's connect?
- React - How to pass props down for the .map function when using functional components
- Can't figure out how to pass props to components when using React Router v5 and Redux
- why we cannot pass boolean value as props in React , it always demands string to be passed in my code
- React router - pass props on routes to child components
- how to pass props to the route when using react router <Link>
- Looking to pass all props using react hooks
- Why do my styled component keyframes error with ts-styled-plugin(9999) in react when using percentage instead of TO/FROM
- React pass props down to all descendant Components
- React Hook Forms How to pass the errors as a props using Typescript
- In how many ways we can pass props to all child components in react
- How to pass props to route components when using useRoutes?
- Why react rerendres components even if props didn't changed?
- react how to pass props to inline css style in components
- How to pass props using react router link v6?
- How do I pass props and other parameters to function using React Hooks?
- React - set state using button and pass it as props
- How to pass props to children components in React
- React how to pass onSubmit handler through props to the components
- How to pass the props value from the other sibling components in React JS
- How to pass props in React Components correctly?
- React Context API, set context state from Child Components instead of passing functions as props
- How to pass props from container component to redux form(component) - react using typescript
- How to pass props to child components when using protected routes?
- How to pass props to react component through routing using react-router?
- can't pass props using Link in react router dom
- How can I pass function using props in React Router Link?
- Using Typescript generics for React Functional Components with eslint props validation
- Using react router, how can I pass component props using a route config?
- React + Typescript + Styled Components pass props to keyframes & conditioning
More Query from same tag
- React Redux mapDispatchToProps vs this.props.dispatch
- React: trying to automatically select newly created list item
- Downloading file with node express app as response
- can i use the tsx extension for test files if using react with typescript
- Join array with svg in jsx
- State is not updating when using React form. I am trying to use the user input to display an order confirmation in a modal
- ReactJs:onClick on a div execute a function and onClick outside of this div execute another function
- chat app using mern stack and socket.io getting slow after sending more than 20 messages
- shouldComponentUpdate in function components
- handleSubmit not working when I try to use the function
- How to call a function and pass parameter in from a map function
- Get text Input Value React
- NextJS: Specify Common Rendering Template
- Component button call a function in parent
- Redux state showing undefined data inserted in stateStore using axios
- React-filepond external CSS is not being applied. I suspect it's a webpack issue
- Clarifai - FACE DETECT - Model does not exist
- "TypeError: kinds.map is not a function." React.js
- Why is my state's value is always undefined?
- Wordpress Gutenberg Autocompleters, no auto completion completes
- Passing a function to a button within dangerouslySetInnerHTML doesn't work
- ReactJS handleChange on every HTML input
- Date Range Picker component not working inside a modal
- useEffect causing component to re-render infinitely
- How to access/reference component values inside a component
- in react file upload not working properly
- React retains the input value after the page is refreshed and keeps it in local storage
- ReactJS. Render component on click in another component (based on class toggle)