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

A bare minimum Redux integration #883

Closed
wants to merge 1 commit into from
Closed

Conversation

koistya
Copy link
Member

@koistya koistya commented Sep 27, 2016

Next steps

  • Register your application store reducers in core/createStore.js
  • Decorate your React components that need to read data from the store with connect(..) middleware from the react-redux package

For more information visit

How to Merge

git checkout -b redux master
git pull https://github.com/koistya/react-starter-kit.git redux
git checkout master
git merge redux

Ref #753, #738, #612, #173.

@joshuamanns
Copy link

This should be the default setup for RSK, in my opinion. Passing data from server to client feels sloppy without at least a minimum redux store such as this.

@jwhchambers
Copy link

Hi @koistya, thanks for all the hard work on this project! I have a quick question regarding this PR. In the react-intl branch, the initial state is assigned using the following:

        {script && (
          <script
            id="source"
            src={script}
            data-initial-state={JSON.stringify(state)}
          />
        )}

However, in this PR, you serialize it instead of stringify:

        {state && <script
          dangerouslySetInnerHTML={{
            __html: `window.APP_STATE=${serialize(state, { isJSON: true })}`,
          }}
        />}
        {script && <script src={script} />}

Then both methods fetch it in client.js. I can see how both work, I was just wondering if there is a preferred approach and what the pros/cons are? Many thanks!

@amilajack
Copy link

This would be great. @koistya what is the status of this?

@koistya
Copy link
Member Author

koistya commented Sep 30, 2016

@jwhchambers deserializing data from a data- attribute on the client might be an expensive operation, on the other hand, if you embed data inside the <script> tag, you need to make sure that you don't expose XSS vulnerability.

@langpavel
Copy link
Collaborator

langpavel commented Oct 3, 2016

I just Integrated this PR into feature/redux and feature/react-intl

@ulani
Copy link
Member

ulani commented May 27, 2021

@koistya thank you very much for this PR! Unfortunately, we have close it due to inactivity. Feel free to re-open it or join our Discord channel for discussion.

NOTE: The main branch has been updated with React Starter Kit v2, using JAM-style architecture.

@ulani ulani closed this May 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants