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

React 18 #46

Merged
merged 7 commits into from
Oct 1, 2022
Merged

React 18 #46

merged 7 commits into from
Oct 1, 2022

Conversation

whitchapman
Copy link
Contributor

Closes #34

Per @tom-sherman's instructions, I forked his react-18 branch and added a couple of commits. I attempted to mirror the React 18.1 documentation:

  • upgraded to react and react-dom 18.1
  • deprecated ReactDOM.hydrate, ReactDOM.unmountComponentAtNode
  • added ReactDOM.Client to encapsulate createRoot, hydrateRoot, and Root module

I'm happy to modify as needed and do any additional work to close #34, but I'm pretty new to ReScript (background in Clojure and OCaml) so please advise on the following:

  • I do not know how to run tests correctly. Running node test/React__test.bs.js did not work
  • Introducing the Client module is my attempt to mirror React 18.1 but may not be the proper way to do things in ReScript
  • There is probably a much more efficient way to detect changes between the alpha and release of React 18 than hunting through documentation and javascript code.
  • If someone with more experience lists the remaining work, I have some time to tackle it.

@jauniuseitmantis
Copy link

maybe somebody have any updates about timeline for merging this PR?

@tom-sherman
Copy link
Contributor

I think these changes would be good land as a stacked diff on top of #35 (ie. after it's been merged)

@rickyvetter what do you think?

@tom-sherman tom-sherman mentioned this pull request Jun 9, 2022
3 tasks
@whitchapman
Copy link
Contributor Author

@tom-sherman I'll rebase and force push whenever #35 is merged, as well as, mark it ready for review.

@whitchapman whitchapman marked this pull request as ready for review July 25, 2022 17:16
@whitchapman
Copy link
Contributor Author

I marked this ready for review for my last 2 commits. This will eventually be rebased once #35 is merged.

@cknitt
Copy link
Member

cknitt commented Sep 25, 2022

@whitchapman @tom-sherman Thank you for your work and sorry for the very long delay. I am currently trying to clean up the repo and to move the pull requests forward.

Would it be possible to have a single React 18 PR (either this one or #35) rebased on master for review? And the other one to be closed?

@whitchapman
Copy link
Contributor Author

@whitchapman @tom-sherman Thank you for your work and sorry for the very long delay. I am currently trying to clean up the repo and to move the pull requests forward.

Would it be possible to have a single React 18 PR (either this one or #35) rebased on master for review? And the other one to be closed?

Absolutely, whatever is easier. I forked @tom-sherman 's repo, so would it be better for me to cherry pick b254874 so that #46 is has all 5 commits? What do you think Tom?

@tom-sherman
Copy link
Contributor

Sounds good!

@whitchapman
Copy link
Contributor Author

Ok, I force pushed with all 5 commits -- I think I did it correctly; although, there are conflicts.

@whitchapman
Copy link
Contributor Author

@tom-sherman Since my fork is from your fork of the original repo, I think you need to sync your fork first before I can sync mine -- how did this get to be so complicated!?

@cknitt
Copy link
Member

cknitt commented Sep 28, 2022

@whitchapman Couldn't you just rebase on the lastest master (d5d9168) and force push?

@whitchapman
Copy link
Contributor Author

My fork doesn't have that commit since Tom's fork doesn't have that commit. I would need to refork directly from rescript-lang and open a new PR -- definitely doable. I'll give it a go.

@cknitt
Copy link
Member

cknitt commented Sep 28, 2022

IMHO it shouldn't matter if your fork has that commit, you should be able to add the rescript-lang/rescript-react repo as a remote in your locally checked out project dir and perform a fetch, then you should have that commit locally and be able to rebase on it.

@whitchapman
Copy link
Contributor Author

Ok, @cknitt I did what you suggested which resulted in modifying the PR to remove the test changes since the test folder has been removed in master.

@cknitt
Copy link
Member

cknitt commented Sep 28, 2022

I think that's fine if the tests have been removed in the meantime.
Looking at the changes, is everything still there that you would expect (except for the removed tests)?

CI is still failing, you need to make some small adjustments in the V3 compatibility modules to fit the changes.

@whitchapman
Copy link
Contributor Author

Yes, my changes are as expected. It has been several months since I last looked at this, and I'm not familiar with the V3 changes. Is there a resource for the V3 changes? I can look at this later today.

@cknitt
Copy link
Member

cknitt commented Sep 28, 2022

Looking at the CI errors, I think it's just about adapting to these changes:

  • ReactDOM.Experimental.root -> ReactDOM.Client.Root.t
  • useTransition does not take a transitionConfig anymore

@cknitt
Copy link
Member

cknitt commented Sep 29, 2022

Sorry!!! Looking again at the discussion in the original PR (#35 (comment)) and also at the TypeScript typedefs for useTransition, I realize my previous comment was wrong and this definition

external useTransition: unit => (bool, (. unit => unit) => unit) = "useTransition"

is actually correct. Let's change it to this in both the React and React_V3 modules.

I think then we are done. 🎉

     * The `useTransition` hook returns two values in an array.
     *
     * The first is a boolean, React’s way of informing us whether we’re waiting for the transition to finish.
     * The second is a function that takes a callback. We can use it to tell React which state we want to defer.

Copy link
Member

@cknitt cknitt left a comment

Choose a reason for hiding this comment

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

Looks good to me! 🎉

@tom-sherman Anything to add from your part?

@cknitt
Copy link
Member

cknitt commented Oct 1, 2022

Ok, merging now. In case anything is still missing or incorrect we'll address it in separate PRs.

@cknitt cknitt merged commit 6d567e3 into rescript-lang:master Oct 1, 2022
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.

React@18 support
4 participants