Redux: [Docs Rewrite] Meta-Issue: Rewrite Examples

Created on 25 Oct 2020  路  15Comments  路  Source: reduxjs/redux

This is a tracking issue to cover all tasks related to rewriting our existing example projects.

Tasks

  • [ ] Decide which examples can be removed (like todos vs todomvc vs todos-flow)
  • [ ] Rewrite remaining examples with Redux Toolkit and React-Redux hooks
docs

Most helpful comment

@giacomocerquone I think it's worth reviewing _all_ the examples, deciding what the _original_ intended purpose was, and then deciding what the overlap is and what should be removed.

I do actually think the tree-view example is useful - this was a big question early on in the life of Redux about "do I just connect the top component, or multiple components?", and it shows components extracting items from the store based on ID as well as recursive rendering. Someone over in Reactiflux was actually trying to port that to hooks as a learning exercise yesterday, which is what prompted me to file this issue.

todomvc is a slightly larger version of todos. This was more relevant when the TodoMVC project was being widely used as a comparison between varying UI frameworks, and it at least _looks_ nicer than the barebones todos project, but tbh it can probably be removed.

Haven't looked at async lately, but yes, it can probably be removed.

I would honestly just go replace counter with the contents of our Redux+JS template for Create-React-App:

https://github.com/reduxjs/cra-template-redux

Flow is dead, effectively. I would delete that one.

On the other hand, I would _consider_ having a counter-ts example that copy-pastes the Redux+TS template for CRA. We ought to at have least one TS-based example in there somewhere.

The other thing to consider is that I've built out a larger real-world-ish app as the example for the "Essentials" tutorial, here:

https://github.com/reduxjs/redux-essentials-example-app

and this TodoMVC-based app for the "Fundamentals" tutorial:

https://github.com/reduxjs/redux-fundamentals-example-app

We're going to keep those repos because I want them to be independently cloneable so people can try out the projects themselves, but we should probably either link to them on the "Examples" docs page, or copy-paste the final versions of the code into projects in the /examples folder.

@zpwebbear : No particular timeline for this. It's just something that crossed my mind yesterday as a thing that needs to be done at some point.

All 15 comments

@markerikson I think I could help to rewrite some examples, but I need to know how fast they must be rewritten.

@markerikson Hi, quick question: for the first task of deciding which examples can be removed, you wanna decide between all the examples or just between the three you mentioned or between the similar ones?

Anyway:

  • I don't see why the tree-view example should be there. Was it for showcasing performances with a large structure inside redux? If that was the use case, we would be better off benchmarking stuff.
    At the same time, I don't think it could be of any help showcasing the usage of it though... basically, I wouldn't keep it.
  • In todos-flow I like the idea of demonstrating how to correctly type a redux project, but I'd use typescript instead
  • todomvc: I think I'm completely missing the point on why this example exists at all. What is it for? What does it showcase? Because I don't really see how the MVC pattern applies in that folder, plus we're in an MVVM library (or whatever React is), so why should we showcase the usage of the MVC pattern with redux?
  • the async project might be deleted in favour of refactoring the real-world example where some async computation is mandatory

Ultimately, I think that all the other examples are ok to keep!

As of now I'm about to refactor the counter example, count me on 馃槂

@giacomocerquone I think it's worth reviewing _all_ the examples, deciding what the _original_ intended purpose was, and then deciding what the overlap is and what should be removed.

I do actually think the tree-view example is useful - this was a big question early on in the life of Redux about "do I just connect the top component, or multiple components?", and it shows components extracting items from the store based on ID as well as recursive rendering. Someone over in Reactiflux was actually trying to port that to hooks as a learning exercise yesterday, which is what prompted me to file this issue.

todomvc is a slightly larger version of todos. This was more relevant when the TodoMVC project was being widely used as a comparison between varying UI frameworks, and it at least _looks_ nicer than the barebones todos project, but tbh it can probably be removed.

Haven't looked at async lately, but yes, it can probably be removed.

I would honestly just go replace counter with the contents of our Redux+JS template for Create-React-App:

https://github.com/reduxjs/cra-template-redux

Flow is dead, effectively. I would delete that one.

On the other hand, I would _consider_ having a counter-ts example that copy-pastes the Redux+TS template for CRA. We ought to at have least one TS-based example in there somewhere.

The other thing to consider is that I've built out a larger real-world-ish app as the example for the "Essentials" tutorial, here:

https://github.com/reduxjs/redux-essentials-example-app

and this TodoMVC-based app for the "Fundamentals" tutorial:

https://github.com/reduxjs/redux-fundamentals-example-app

We're going to keep those repos because I want them to be independently cloneable so people can try out the projects themselves, but we should probably either link to them on the "Examples" docs page, or copy-paste the final versions of the code into projects in the /examples folder.

@zpwebbear : No particular timeline for this. It's just something that crossed my mind yesterday as a thing that needs to be done at some point.

@markerikson

All clear, tbh don't like the idea of copying stuff though. For the counter example it's ok I suppose, but for everything else that might have even just a few changes in time, I'd leave a link so that they don't have to be synced every time.

So I'm about to prepare a PR for:

  • the deletion of the todomvc and the async examples
  • the replacement of the counter example with the cra-template-redux
  • adding the links of the fundamentals and the redux essentials example (still don't understand why we should call them MVC examples...)

Actually instead of linking the stuff, we could also copy the redux-fundamentals-example-app repo inside the example repo, but I've never experimented with this kind of configuration

You mean like a git submodule or subtree?

You mean like a git submodule or subtree?

yes, or even simpler, symlinks: https://stackoverflow.com/a/4660048/2809729

I don't think you can symlink across repositories, unless you require users always clone both repositories in the same place relatively, but they that would probably break on GitHub. GitHub supports submodules, though I'm not sure about subtrees as they're newer.

@nickmccurdy clear enough for me. Let's just link them in the README, once some contributor, or directly mark, will have tested this solution (if he likes it) we will change it!

I'm working on real-world

This is made redundant by #3565. I would still like to move the examples out of this repo, as they add a ton of weight to the test process and a lot of noise to the git history.

I'd forgotten that that PR existed.

Biggest issue is that there are external links pointing to those folders. At a bare minimum, we would need to replace all of those folders' contents with a README that points to the new location.

We can submodule it.

@markerikson I would prefer to rewrite the shopping-cart. Do I need to use typescript to show the whole might of RTK?
Do I need to create the PR at the very beginning of work to be able to see the process of rewriting, or we just will replace the example folder with the single commit from PR when work will be done?

I didn't write it, but apart from the #3919 which is reorganizing the whole examples folder (and I still don't know if it will have to be closed), I'd like to refactor the "todos"

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cloudfroster picture cloudfroster  路  3Comments

benoneal picture benoneal  路  3Comments

parallelthought picture parallelthought  路  3Comments

ms88privat picture ms88privat  路  3Comments

vraa picture vraa  路  3Comments