Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: new extension vike-react-redux (closes #87) #161

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

phonzammi
Copy link
Member

@phonzammi phonzammi commented Jan 28, 2025

#87

@brillout
Copy link
Member

Neat! Let me know when you want me to have a look at it.

@phonzammi
Copy link
Member Author

I think the basic integration is good enough, but I’m not too familiar with more complex use cases. Let me know what you think.

I’ll polish the README once we’ve covered everything.

@brillout brillout changed the title feat: new extension vike-react-redux feat: new extension vike-react-redux (fix #87) Jan 30, 2025
@brillout brillout changed the title feat: new extension vike-react-redux (fix #87) feat: new extension vike-react-redux (closes #87) Jan 30, 2025
},
"peerDependencies": {
"@reduxjs/toolkit": ">=2",
"react-redux": ">=9",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about we define react-redux and @reduxjs/toolkit as both dependency and peerDependencies? Rationale: vikejs/vike#2070. Making vike-react-redux even more zero config ✨

"typescript": "^5.5.3",
"vike": "^0.4.211",
"vike-react": "^0.5.12",
"vite": "^5.4.0"
Copy link
Member

@brillout brillout Jan 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need vite?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intervention++

if (pageContext.config.redux) {
const createStore = pageContext.config.redux.createStore
if (createStore) {
pageContext.config.redux.store = createStore()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless we have a reason, let's try to treat pageContext.config as immutable.

How about this?

  • pageContext.reduxStore
  • pageContext.reduxState

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The store contains functions, so when we try to access it on the client side, it can't be serialized.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know, that's why I'm suggesting two different pageContext props.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Note that I didn't Intervention++ because I did guess that you mutated pageContext.config because of passToClient 😉)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, are you suggesting we do it like this ?

  • pageContext.reduxStore for the client-side
  • pageContext.config.redux.store for server-side

Copy link
Member

@brillout brillout Jan 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should work if we use pageContext.reduxStore for both client- and server-side without adding it to passToClient.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, thank you. Sorry, I didn't know

@brillout
Copy link
Member

The overall integration LGTM! Very exciting, vike-react-redux is a major integration 🚀

@brillout
Copy link
Member

Didn't look at the README, let me know when you want me to.

@brillout
Copy link
Member

How about we create an example for this examples/redux/? For important integrations I feel like it's worth it.

@brillout
Copy link
Member

Just pushed a polish commit. Intervention++ (most notably the missing type in import type { PageContext } and removing the superfluous ? which makes the code a bit slower to read). I wouldn't be that picky about polishing, but since we want users to eject extensions they might as well eject something pretty 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants