From react-redux 6 and further, people won't be able to access store from outside of the Provider Context. I mean, they can still try and sometimes they think that they succeeded, BUT, the underlying truth is that they will be probably failing every single time.
As from the version mentioned and above, if you access the state from outside of the reducer context while doing an action, you'll see a really scaring error showing up. That should be in there ever since day 1 in Redux, but it wasn't and now it is, which will simply prevent people from doing risky stuff like exposing store in a variable to access it in components/methods without using a connect or a hook ( react-redux > 7 ).
In one of the apps that I work with, our team had the terrible habit of doing that. When I realised it was too late and that pattern was already spread all over the application, thankfully during react-redux migration those errors started to occur and I finally had a extremely powerful reason to convince people that it was wrong, and I finally could get rid of that extremely painful and risky anti pattern.
So, thank you react-redux for doing that! Icing sugar is the store as prop deprecation, but, that shouldn't be even considered a breaking since no one should be using ( but, yes, we were using it too ).
Top comments (0)