reduxjs / redux

A JS library for predictable global state management
https://redux.js.org
MIT License
60.94k stars 15.27k forks source link

Update part-3-data-flow.md #4685

Closed monchipi closed 8 months ago

monchipi commented 8 months ago

I would like to fix the sample code in the file "store.js" to fix a problem that is not working properly.

--- name: :memo: Documentation Fix about: fix existing documentation page problem ---.

Checklist.

Is there a document page that needs to be fixed?

What is the problem?

It does't work.

What changes will this PR make to correct the problem?

Change the function to variable.

codesandbox-ci[bot] commented 8 months ago

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

netlify[bot] commented 8 months ago

Deploy Preview for redux-docs ready!

Name Link
Latest commit 20484ae270a3b424075412838fe84f07c6c125f6
Latest deploy log https://app.netlify.com/sites/redux-docs/deploys/65f8031cb7efa500087efb56
Deploy Preview https://deploy-preview-4685--redux-docs.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

phryneas commented 8 months ago

That is currently right, your change would break the tutorial.

In Part 2, a default import is used to import the store:

// this is a default import like in part 2
import store from './app/store'
// this would be a named import, but we don't show that anywhere for `store`
import { store } from './app/store'

That also means that here in part 3, a default export has to be used, or it wouldn't be working.

Did you see another kind of import for store somewhere else in the tutorials?

monchipi commented 8 months ago

Thank you for your review and comment. Regarding your question about the import for 'store' in the tutorials, I didn't see any other type of import. If we don't modify it, the code on line 6 in 'index.js' won't work correctly, which is why nothing appears on my screen.

Have you completed the Part 3 tutorial?

EskiMojo14 commented 8 months ago

are you sure that you didn't accidentally write a named import in your local project?

monchipi commented 8 months ago

@EskiMojo14 Thank you for your review and comment. I didn't write accidentally. I have cloned this project and modify two files named "features/posts/postsSlice.js" and "app/store.js" according to the article.

timdorr commented 8 months ago

If you're following through, this is all covered in Part 2, specifically with the Provide The Store section: https://redux.js.org/tutorials/essentials/part-2-app-structure#providing-the-store

You can see those exports from app/store.js are all default, not named. You have copied something incorrectly if you need to switch to a named export at that point.

Regardless, this doc is correct as-is. Thanks, but this PR will break the tutorial.