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

Simplify ref type #521

Merged
merged 1 commit into from
Apr 27, 2020
Merged

Simplify ref type #521

merged 1 commit into from
Apr 27, 2020

Conversation

cknitt
Copy link
Contributor

@cknitt cknitt commented Apr 16, 2020

@rickyvetter as discussed on Discord:

Now that we have records as objects in BS7, let's simplify the type for React refs to:

type ref('value) = {mutable current: 'value};

Ref.t, Ref.current and Ref.setCurrent can be deprecated and removed in a later version.

@peterpme peterpme added the 0.8.0 label Apr 22, 2020
@rickyvetter rickyvetter merged commit 1bebae0 into reasonml:master Apr 27, 2020
@flash-gordon flash-gordon mentioned this pull request May 30, 2020
@flash-gordon
Copy link
Contributor

Just two lines clarifying what the upgrade process looks like:

Accessing current value

Before:

reactRef->React.Ref.current->Js.Nullable.toOption

After

reactRef.current->Js.Nullable.toOption

Type aliases

Before:

type aliasedRef = React.Ref.t(Js.nullable(Dom.element));

After:

type aliasedRef = React.ref(Js.nullable(Dom.element));

Updating ref value

Before:

React.Ref.setCurrent(elRef, None);

After:

elRef.current = None;

I also sent a doc patch.

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.

4 participants