As I see this, your problem boils down to: How do you mix Redux with stateful components (legacy/third party)?
You are right, Redux is better suited for
controlled components, that is, components that are mostly stateless and are supposed to receive everything as
props. Just keep in mind that having some state doesn't necessarily make the component unusable in Redux. Example: For an Autocomplete component, the "open" state (whether or not the dropdown is visible) doesn't necessarily has to be controlled by Redux. So, depending on the how the component is implemented, you're definitely having a hard time integrating it into Redux, or maybe not.
You have 2 options: You either refactor the problematic components so they're now controlled, or you don't keep their state on Redux (you're not required to). The answer will vary depending on the circumstances. There's not a globally accepted solution for your case, that I know of.
Remember: There is no magic to redux; it's just a wrapper/container that is setting the props for you.
You can even use
shouldComponentUpdate to manage how changing your stateful component's props should trigger the rendering.
Or leverging on
areStatesEqual areStatePropsEqual areOwnPropsEqual areMergedPropsEqual
for greater control
Do I have to put all my state into Redux? Should I ever use React's setState()?
There is no “right” answer for this. Some users prefer to keep every single piece of data in Redux, to maintain a fully serializable and controlled version of their application at all times. Others prefer to keep non-critical or UI state, such as “is this dropdown currently open”, inside a component's internal state.
Using local component state is fine. As a developer, it is your job to determine what kinds of state make up your application, and where each piece of state should live. Find a balance that works for you, and go with it.
There's a bunch more info there -- worth reading the whole thing.
- How do I use stateful components with redux?
- How do I use local state along with redux store state in the same react component?
- How should I use redux with nested subcomponents that won't be reused?
- How to use redux-toolkit createSlice with React class components
- How redux work when multiple components use parts of complex objects for it's source
- How to use Redux Form Wizard with permanent URLS per page
- How to use HOC with redux compose and Typescript
- How to use custom props and theme with material-ui styled components API (Typescript)?
- How to use useEffect hook properly with array dependency. I passed state from redux store and still my component renders infinitely
- How to use the updated value in redux store immediately after the action is dispatched in react js functional components
- How to properly use redux with react-native navigation
- How to use inheritance with React components and es6 classes
- How to use getChildContext with functional components
- How to use Redux store in one component without Provider but with connect, because children aren't necessary?
- How to use react-datepicker with redux form?
- How can i use suspense with redux
- How can I access a local JSON file with Redux to use throughout my React app?
- How to use document.getElementById() with styled components in react?
- How can I use a React 16.3 Context provider with redux store?
- How do i use styled components with dynamic imports
- How to use router for switching between components with a key value pair in react
- How to Bind different react components with the same react-router route depending on redux state?
- How to write unit test redux connected components in next.js app with Jest end Enzyme
- How to use React BluePrint components with TypeScript?
- How to reuse the same Redux Saga for multiple React components with their own state?
- How to use getFieldDecorator with stateless components
- how to use window.matchMedia in next.js with style components theme?
- How to use Redux devtools with Nextjs?
- React. the order of the render method of nested components and how does it work with Redux
- How to use react-redux with next js and class components
More Query from same tag
- unable to access dynamic object property and store to state in react
- How to drag and drop html element in inner card or box?
- Trying to view data as pdf , pdf is blank
- ClassName is not being passed to Objects
- React js - unable to set state of variable properly
- How to get index of rows in AgGrid?
- Functions are not valid as a React Child - When trying to destructure each icon inside a map
- what is difference between the following methods about React element type
- How to create common Header and footer for all child pages in reactjs?
- StoryBook addon-docs: "No props found for this component" using TypeScript
- How to change the handleChange action based on the select input using react?
- Don't require props, when using component with HOC
- Switching from class component to functional components
- How do I sort specific questions to a specific section?
- Is there a way to get the qqfilename and qquuid that was given to the server?
- How to rewrite class component to React Functional?
- mongodb : fetch API POST request returns a strange response
- How to display data in column in react
- Render HTMLDivElement in React
- Symfony twig + reactJS
- How does one make an image path fetched from mongodb work in react project?
- How to dynamically show or hide form fields depending on the state of a BooleanInput field in react-admin?
- React / Redux - losing state when direct to other route
- After Resetting the array the color of bars remain green
- Redux - returning an array instead of an object in the reducer
- React Google Maps - Marker positions are not binding dynamically
- How to change routes in gatsby without Link component?
- React image upload component
- NextJS 9.3 Link not a constructor function for JSX elements