reactjs / react-gradual-upgrade-demo

Demonstration of how to gradually upgrade an app to a new version of React

Home Page:https://reactjs.org/blog/2020/08/10/react-v17-rc.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question: why this project needs to copy files from src/shared to src/{legacy,modern}/shared?

JLarky opened this issue · comments

Sorry for my ignorance, but I never saw this approach before.

Why is this needed? Should people who do not use two react versions of the app be aware of this approach? Will something like that work with typescript?

p.s. just a note on presentation, it would be cool to see how you take this demo working with react 16 and convert it to gradual upgrade demo, instead of the whole app being in one "initial commit" where it's hard to reason about which parts are relevant to what.

After reading README more carefully I think it answers some of my questions :) I think the main one that I'm still confused by is: why wouldn't you have it in src/modern/shared and just copy it to src/legacy/shared? :) seems like less work and your typescript and editor will be less confused on which file you should be editing (example I edit src/modern/HomePage.js and ctrl+click on <Clock > in VS code. It will open me src/modern/shared/Clock.js which is an auto-generated one (but I won't see any signs of that except for the fact that all changes to this file will be eventually lost). It will still be pretty bad :) but maybe like 50% less bad :)

commented

Seems like you answered all of your questions. :-)

I think ideally there would be a more robust setup that makes it clear the files are auto-generated. I would gladly take that as a PR if it doesn't complicate the codebase.