reactjs - How do I use stateful components with redux? -


i trying redux right , excited ideas behind it, first real task ruined whole thing.

in redux should store immutable state , produce reducers transform it. means every state reproduced given previous state , list of actions fired.

but if need store third-party/legacy stateful object? example may gallery or websocket client. assume i'm able use reducers start/stop/manage somehow, state have no longer stateless , not guaranteed repeatable given list of reducers (websocket client may generate new session id or unable maintain connection).

what convenient way solve these issues?

thanks.

as see this, problem boils down to: how mix redux stateful components (legacy/third party)?

you right, redux better suited controlled components, is, components stateless , supposed receive props. keep in mind having state doesn't make component unusable in redux. example: autocomplete component, "open" state (whether or not dropdown visible) doesn't has controlled redux. so, depending on how component implemented, you're having hard time integrating redux, or maybe not.

you have 2 options: either refactor problematic components they're controlled, or don't keep state on redux (you're not required to). answer vary depending on circumstances. there's not globally accepted solution case, know of.


Comments