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

Remove ReactDOM.props #764

Merged
merged 9 commits into from
Sep 7, 2023
Merged

Remove ReactDOM.props #764

merged 9 commits into from
Sep 7, 2023

Conversation

davesnx
Copy link
Member

@davesnx davesnx commented Sep 3, 2023

PR removing ReactDOM.props

Copy link
Collaborator

@jchavarri jchavarri left a comment

Choose a reason for hiding this comment

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

Sorry, I am not sure I understand the changes, is the removal of props related to the fix for memoCustomCompareProps? Could you share more info about the latter?


/* This list isn't exhaustive. We'll add more as we go. */
/*
* Watch out! There are two props types and the only difference is the type of ref.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Were you aware of this? Seems the deletion of props will lead to unsound types?

Copy link
Member Author

Choose a reason for hiding this comment

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

Unsound types?

The difference is props.ref is Js.nullable(Dom.element) => unit which is the old api from react where you pass a callback to capture the domNode.

It just not used neither the ppx, neither on our monorepo neither github search: https://github.com/search?q=ReactDOM.props+language%3Aocaml&type=code

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't know. I spent some time trying to understand why this was added but I couldn't find much, besides that it was added when hooks were introduced in #351.

One thing I noticed is that ReactDOM.createDOMElementVariadic is not used anywhere. Maybe it could go as part of this PR.

Copy link
Collaborator

Choose a reason for hiding this comment

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

hey @rickyvetter 👋 this is a long shot, as it's been years already, but maybe you remember why two types props and domProps were needed? Just out of pure curiosity :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Hey folks! Oof this was a while ago. I'm pretty sure this is a combination of:

  1. We wanted to support useRef refs only in function components
  2. We had to support callback refs in class components
  3. We absolutely refused to introduce a runtime
  4. I wasn't as good at OCaml as I am now and maybe could've found a better way with those same three constraints today, but at the time this seemed like the obvious/only solution.

Copy link
Member Author

Choose a reason for hiding this comment

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

2 is gone now and we aren't strong about 0 runtime neither, I obviously prefer zero runtime when possible but without being super strict.

WDYT @jchavarri ?

Copy link
Collaborator

@jchavarri jchavarri Sep 7, 2023

Choose a reason for hiding this comment

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

Thanks Ricky!

I wasn't as good at OCaml as I am now

🤘

we aren't strong about 0 runtime neither, I obviously prefer zero runtime when possible but without being super strict

@davesnx To clarify, there is no runtime addition involved in this PR, right?

WDYT @jchavarri ?

This is some code that breaks after this change:

  let foo = ref(None);
  let setSectionRef = theRef => {
    foo := Js.Nullable.toOption(theRef);
  };
  [@react.component]
  let make = () => {
    ReactDOM.createElement(
      "div",
      ~props=ReactDOM.props(~ref=setSectionRef, ()),
      [||],
    );
  };

However

  • I don't expect many people to be calling createElement manually
  • and after the jsx additions, we only use this function in the ppx to create fragments, where one can't pass refs (because it's just <>).

So I guess it's safe to do the change? 👍 I would still think it'd be great to document it in the release notes.

@davesnx davesnx changed the title Fix rules for testing Remove ReactDOM.props Sep 4, 2023
@davesnx
Copy link
Member Author

davesnx commented Sep 4, 2023

My bad, I was working offline and made the change on the same branch. Changes weren't related. Split the work of memo here: #766

…ReactDOM-domProps

* 'main' of github.com:/reasonml/reason-react:
  Fix rules for reason under with-test (#762)
  fix opam formula (#763)
  depexts: expand to react 17 (#761)
…ReactDOM-domProps

* 'main' of github.com:/reasonml/reason-react:
  Allow memoCustomCompareProps on ppx (#766)
@davesnx
Copy link
Member Author

davesnx commented Sep 6, 2023

One thing I noticed is that ReactDOM.createDOMElementVariadic is not used anywhere. Maybe it could go as part of this PR.

To remove the APIs I'm working in #768 and later remove the unused APIs. Does it sound good?

All of this should go before 0.12

@davesnx davesnx merged commit f5f28aa into main Sep 7, 2023
2 of 4 checks passed
jchavarri added a commit that referenced this pull request Sep 7, 2023
* main:
  Remove ReactDOM.props (#764)
  update package-lock.json (#772)
davesnx added a commit that referenced this pull request Sep 7, 2023
…-test-for-inference-regression

* 'main' of github.com:/reasonml/reason-react:
  Abstract bindings on ppx (#768)
  Remove ReactDOM.props (#764)
  update package-lock.json (#772)
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.

3 participants