Comments (5)
Hi, glad to hear you're still interested; I absolutely do have plans and am currently working on a full rewrite! Unfortunately, I didn't manage to finish it in the semester break which is why it might still take a few month in the worst case (hopefully not). Here are my plans:
- Move away from
redux-persist
andredux-persist-cookie-storage
as the machinery is pretty heavy for the simple task andredux-persist-cookie-storage
doesn't seem to be maintained.redux-cookies-middleware
seemed to be a good alternative at first, but it has not been maintained for a while now as well. Hence, I'm currently building a tiny custom Redux middleware for the use case. This also allows us to tackle #2 with a warning in dev mode. - Change the interface: I never really liked the "wrapping
next-redux-wrapper
" part. It couples the two packages quite tightly. With a custom middleware in place, wrapping themakeStore
function is all it takes, I guess. - The
HYDRATE
reducer: I think we can make it such that people do not need to alter it for next-redux-cookie-wrapper. Instead, we can do some magic in our middleware:- In the
getServerSideProps
case, we always want the latest cookies from the server to take precedence. We do not have to merge anything as the server also has the client state (ignoring the time between request and response here where the client state might potentially change). - In the
getStaticProps
case, the server does not have client cookies available and incoming state (from the server) in the client can by default be ignored (i.e., the client state remains unaltered). However, there may also be use cases that require custom handling in theHYDRATE
reducer, so this must still be possible.
- In the
What do you think; any mistakes in my assumptions? If you find something odd or know better alternatives, please let me know! :)
from next-redux-cookie-wrapper.
@bjoluc Thank you for job! One small question, How will you organize the nested persist reducers. I mean the following: let's say we have a store with nested data:
root: {
user,
messages
... etc
}
Let's say for a user I store data in a cookie.
I messages I store localStorage.
How can I pass this nesting?
from next-redux-cookie-wrapper.
🎉 This issue has been resolved in version 2.0.0 🎉
The release is available on:
Your semantic-release bot 📦🚀
from next-redux-cookie-wrapper.
@VictorPullzz Hey! Well, currently you should be able to use something like
persistConfig: {
whitelist: ["root.user"],
},
when you call withReduxCookiePersist
. I did never try the current version of next-redux-cookie-wrapper
alongside a plain redux-persist
setup though, nor do I expect that to work. In the next version, however, this should work without any problems since redux-persist
is off the next-redux-cookie-wrapper
dependencies then. I guess we'll have something like a subtrees
config option then where you can add "root.user" to be synced with cookies.
from next-redux-cookie-wrapper.
@VictorPullzz Hey! Well, currently you should be able to use something like
persistConfig: { whitelist: ["root.user"], },when you call
withReduxCookiePersist
. I did never try the current version ofnext-redux-cookie-wrapper
alongside a plainredux-persist
setup though, nor do I expect that to work. In the next version, however, this should work without any problems sinceredux-persist
is off thenext-redux-cookie-wrapper
dependencies then. I guess we'll have something like asubtrees
config option then where you can add "root.user" to be synced with cookies.
Thanks for answer!
I hope that you will be able to upgrade to the new version of next-redux-wrapper :)
I'm currently trying to connect your plugin and next-redux-wrapper v6, but so far there is little progress :D
from next-redux-cookie-wrapper.
Related Issues (20)
- Hydrate state from cookies without server side rendering HOT 6
- Changing compress config to false throws 'SyntaxError: Unexpected token N in JSON at position 0' error HOT 1
- how set refresh token in cookie HOT 10
- how to add redux-logger in diff env HOT 1
- Ability to hydrate all pages without getServerSideProps and connect. HOT 4
- __NEXT_REDUX_WRAPPER_HYDRATE__ cookie bug HOT 15
- State from Cookies not set back after browser reload HOT 2
- Getting error: TypeError: store.getState is not a function HOT 1
- Question: Authentication HOT 1
- Error: Text content does not match server-rendered HTML in newer NextJS version HOT 9
- middleware sometime can't get subtrees HOT 3
- Bug: "Cannot set headers after they are sent to the client" HOT 1
- Expose functions to manually parse cookies HOT 1
- Store Value Stored In Cookies Defaulting To Store Initial Value When Redirected From An External Url HOT 4
- SSR store missing cookie data in Next 13 HOT 7
- Error: Unexpected token "=", on Safari (=< 13.1) HOT 12
- What happens if we store subtrees in cookie whose size exceeds 4096 bytes ? HOT 1
- Error: Hydration failed because the initial UI does not match what was rendered on the server. HOT 1
- Problem of hydration from the cookie data HOT 1
- Sync client state with cookies HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from next-redux-cookie-wrapper.