Skip to content

Commit

Permalink
Add ref types. (facebook#365)
Browse files Browse the repository at this point in the history
  • Loading branch information
cknitt authored and MoOx committed Apr 13, 2019
1 parent 5999c90 commit 5343b0a
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 22 deletions.
13 changes: 9 additions & 4 deletions bs-react-native-next/src/components/FlatList.re
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
type element;
type ref = React.Ref.t(Js.nullable(element));

type separatorComponentProps('item) = {
.
"highlighted": bool,
Expand All @@ -7,6 +10,8 @@ type separatorComponentProps('item) = {
[@react.component] [@bs.module "react-native"]
external make:
(
~ref: ref=?,
// FlatList props
~_ItemSeparatorComponent: React.component(separatorComponentProps('item))
=?,
~columnWrapperStyle: Style.t=?,
Expand Down Expand Up @@ -177,9 +182,9 @@ type scrollToEndOptions;
[@bs.obj]
external scrollToEndOptions: (~animated: bool=?, unit) => scrollToEndOptions =
"";
[@bs.send] external scrollToEnd: ReactDOMRe.Ref.t => unit = "scrollToEnd";
[@bs.send] external scrollToEnd: ref => unit = "scrollToEnd";
[@bs.send]
external scrollToEndWithOptions: (ReactDOMRe.Ref.t, scrollToEndOptions) => unit =
external scrollToEndWithOptions: (ref, scrollToEndOptions) => unit =
"scrollToEnd";

type scrollToIndexParams;
Expand Down Expand Up @@ -214,6 +219,6 @@ external scrollToOffsetParams:
[@bs.send]
external scrollToOffset: scrollToOffsetParams => unit = "scrollToOffset";

[@bs.send] external recordInteraction: ReactDOMRe.Ref.t => unit = "";
[@bs.send] external recordInteraction: ref => unit = "";

[@bs.send] external flashScrollIndicators: ReactDOMRe.Ref.t => unit = "";
[@bs.send] external flashScrollIndicators: ref => unit = "";
11 changes: 8 additions & 3 deletions bs-react-native-next/src/components/ScrollView.re
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
type element;
type ref = React.Ref.t(Js.nullable(element));

[@react.component] [@bs.module "react-native"]
external make:
(
~ref: ref=?,
// ScrollView props
~alwaysBounceHorizontal: bool=?,
~alwaysBounceVertical: bool=?,
~automaticallyAdjustContentInsets: bool=?,
Expand Down Expand Up @@ -137,9 +142,9 @@ type scrollToEndOptions;
external scrollToEndOptions:
(~animated: bool=?, ~duration: float=?, unit) => scrollToEndOptions =
"";
[@bs.send] external scrollToEnd: ReactDOMRe.Ref.t => unit = "scrollToEnd";
[@bs.send] external scrollToEnd: ref => unit = "scrollToEnd";
[@bs.send]
external scrollToEndWithOptions: (ReactDOMRe.Ref.t, scrollToEndOptions) => unit =
external scrollToEndWithOptions: (ref, scrollToEndOptions) => unit =
"scrollToEnd";

[@bs.send] external flashScrollIndicators: ReactDOMRe.Ref.t => unit = "";
[@bs.send] external flashScrollIndicators: ref => unit = "";
14 changes: 9 additions & 5 deletions bs-react-native-next/src/components/SectionList.re
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
type element;
type ref = React.Ref.t(Js.nullable(element));

[@react.component] [@bs.module "react-native"]
// VirtualizedSectionList props
external make:
(
~ref: ref=?,
// SectionList props
~sections: array(VirtualizedSectionList.section('item)),
~renderItem: VirtualizedSectionList.renderItemCallback('item),
~renderSectionHeader: VirtualizedSectionList.renderSectionHeaderCallback(
Expand Down Expand Up @@ -180,9 +184,9 @@ type scrollToEndOptions;
[@bs.obj]
external scrollToEndOptions: (~animated: bool=?, unit) => scrollToEndOptions =
"";
[@bs.send] external scrollToEnd: ReactDOMRe.Ref.t => unit = "scrollToEnd";
[@bs.send] external scrollToEnd: ref => unit = "scrollToEnd";
[@bs.send]
external scrollToEndWithOptions: (ReactDOMRe.Ref.t, scrollToEndOptions) => unit =
external scrollToEndWithOptions: (ref, scrollToEndOptions) => unit =
"scrollToEnd";

type scrollToIndexParams;
Expand Down Expand Up @@ -217,6 +221,6 @@ external scrollToOffsetParams:
[@bs.send]
external scrollToOffset: scrollToOffsetParams => unit = "scrollToOffset";

[@bs.send] external recordInteraction: ReactDOMRe.Ref.t => unit = "";
[@bs.send] external recordInteraction: ref => unit = "";

[@bs.send] external flashScrollIndicators: ReactDOMRe.Ref.t => unit = "";
[@bs.send] external flashScrollIndicators: ref => unit = "";
9 changes: 7 additions & 2 deletions bs-react-native-next/src/components/TouchableOpacity.re
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
type element;
type ref = React.Ref.t(Js.nullable(element));

[@react.component] [@bs.module "react-native"]
external make:
(
~ref: ref=?,
// TouchableOpacity props
~accessible: bool=?,
~accessibilityLabel: string=?,
~accessibilityComponentType: [@bs.string] [
Expand Down Expand Up @@ -48,5 +53,5 @@ external make:
"TouchableOpacity";

[@bs.send]
external setOpacityTo: (ReactDOMRe.Ref.t, float, float) => unit =
"setOpacityTo";
external setOpacityTo: (ref, ~value: float, ~duration: float) => unit =
"setOpacityTo";
13 changes: 9 additions & 4 deletions bs-react-native-next/src/components/VirtualizedList.re
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
type element;
type ref = React.Ref.t(Js.nullable(element));

type renderItemProps('item) = {
.
"item": 'item,
Expand Down Expand Up @@ -74,6 +77,8 @@ type viewabilityConfigCallbackPairs('item) =
[@react.component] [@bs.module "react-native"]
external make:
(
~ref: ref=?,
// VirtualizedList props
~_CellRendererComponent: cellRendererComponent('item)=?,
~_ListEmptyComponent: React.element=?,
~_ListFooterComponent: React.element=?,
Expand Down Expand Up @@ -230,9 +235,9 @@ type scrollToEndOptions;
[@bs.obj]
external scrollToEndOptions: (~animated: bool=?, unit) => scrollToEndOptions =
"";
[@bs.send] external scrollToEnd: ReactDOMRe.Ref.t => unit = "scrollToEnd";
[@bs.send] external scrollToEnd: ref => unit = "scrollToEnd";
[@bs.send]
external scrollToEndWithOptions: (ReactDOMRe.Ref.t, scrollToEndOptions) => unit =
external scrollToEndWithOptions: (ref, scrollToEndOptions) => unit =
"scrollToEnd";

type scrollToIndexParams;
Expand Down Expand Up @@ -267,6 +272,6 @@ external scrollToOffsetParams:
[@bs.send]
external scrollToOffset: scrollToOffsetParams => unit = "scrollToOffset";

[@bs.send] external recordInteraction: ReactDOMRe.Ref.t => unit = "";
[@bs.send] external recordInteraction: ref => unit = "";

[@bs.send] external flashScrollIndicators: ReactDOMRe.Ref.t => unit = "";
[@bs.send] external flashScrollIndicators: ref => unit = "";
13 changes: 9 additions & 4 deletions bs-react-native-next/src/components/VirtualizedSectionList.re
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
type element;
type ref = React.Ref.t(Js.nullable(element));

type renderItemProps('item) = {
.
"item": 'item,
Expand All @@ -21,6 +24,8 @@ and renderSectionHeaderCallback('item) =
[@react.component] [@bs.module "react-native"]
external make:
(
~ref: ref=?,
// VirtualizedSectionList props
~sections: array(section('item)),
~renderItem: renderItemCallback('item),
~renderSectionHeader: renderSectionHeaderCallback('item)=?,
Expand Down Expand Up @@ -193,9 +198,9 @@ type scrollToEndOptions;
[@bs.obj]
external scrollToEndOptions: (~animated: bool=?, unit) => scrollToEndOptions =
"";
[@bs.send] external scrollToEnd: ReactDOMRe.Ref.t => unit = "scrollToEnd";
[@bs.send] external scrollToEnd: ref => unit = "scrollToEnd";
[@bs.send]
external scrollToEndWithOptions: (ReactDOMRe.Ref.t, scrollToEndOptions) => unit =
external scrollToEndWithOptions: (ref, scrollToEndOptions) => unit =
"scrollToEnd";

type scrollToIndexParams;
Expand Down Expand Up @@ -230,6 +235,6 @@ external scrollToOffsetParams:
[@bs.send]
external scrollToOffset: scrollToOffsetParams => unit = "scrollToOffset";

[@bs.send] external recordInteraction: ReactDOMRe.Ref.t => unit = "";
[@bs.send] external recordInteraction: ref => unit = "";

[@bs.send] external flashScrollIndicators: ReactDOMRe.Ref.t => unit = "";
[@bs.send] external flashScrollIndicators: ref => unit = "";

0 comments on commit 5343b0a

Please sign in to comment.