Skip to content

Commit 48aeba2

Browse files
committed
Fix renderSectionHeader/Footer
There are some [bs] annotations so that there's no currying (for better performance)
1 parent 3e756e2 commit 48aeba2

File tree

3 files changed

+30
-17
lines changed

3 files changed

+30
-17
lines changed

lib/js/src/components/sectionList.js

Lines changed: 12 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/sectionList.re

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,6 @@ let renderItem = (reRenderItem: renderBag('item) => ReasonReact.reactElement) :
6767

6868
let section = (~data, ~key=?, ~renderItem=?, ()) => {data, key, renderItem};
6969

70-
let renderSectionAffix =
71-
fun
72-
| None => None
73-
| Some(f) =>
74-
Some(((data: {. "section": jsSection('item)}) => data##section |> jsSectionToSection |> f));
75-
7670
let sections = (reSections) : sections('item) =>
7771
Array.map(
7872
(reSection) => {
@@ -111,6 +105,12 @@ type viewToken('item) = {
111105
"section": section('item)
112106
};
113107

108+
type renderAccessoryView('item) =
109+
[@bs] (jsSection('item) => ReasonReact.reactElement);
110+
111+
let renderAccessoryView = (renderer) =>
112+
[@bs] ((section) => [@bs] renderer(jsSectionToSection(section)));
113+
114114
let make:
115115
(
116116
~sections: sections('item),
@@ -133,8 +133,8 @@ let make:
133133
=?,
134134
~onRefresh: unit => unit=?,
135135
~refreshing: bool=?,
136-
~renderSectionHeader: section('item) => ReasonReact.reactElement=?,
137-
~renderSectionFooter: section('item) => ReasonReact.reactElement=?,
136+
~renderSectionHeader: renderAccessoryView('item)=?,
137+
~renderSectionFooter: renderAccessoryView('item)=?,
138138
~stickySectionHeadersEnabled: bool=?,
139139
array(ReasonReact.reactElement)
140140
) =>
@@ -180,8 +180,8 @@ let make:
180180
"onRefresh": from_opt(onRefresh),
181181
"onViewableItemsChanged": from_opt(onViewableItemsChanged),
182182
"refreshing": from_opt(UtilsRN.optBoolToOptJsBoolean(refreshing)),
183-
"renderSectionHeader": from_opt(renderSectionHeader |> renderSectionAffix),
184-
"renderSectionFooter": from_opt(renderSectionFooter |> renderSectionAffix),
183+
"renderSectionHeader": from_opt(renderSectionHeader),
184+
"renderSectionFooter": from_opt(renderSectionFooter),
185185
"stickySectionHeadersEnabled":
186186
from_opt(UtilsRN.optBoolToOptJsBoolean(stickySectionHeadersEnabled))
187187
}

src/components/sectionList.rei

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ type separatorComponent('item);
4141
let separatorComponent:
4242
(separatorProps('item) => ReasonReact.reactElement) => separatorComponent('item);
4343

44+
type renderAccessoryView('item);
45+
46+
let renderAccessoryView:
47+
([@bs] (section('item) => ReasonReact.reactElement)) =>
48+
renderAccessoryView('item);
49+
4450
type viewToken('item) = {
4551
.
4652
"index": Js.undefined(int),
@@ -72,8 +78,8 @@ let make:
7278
=?,
7379
~onRefresh: unit => unit=?,
7480
~refreshing: bool=?,
75-
~renderSectionHeader: section('item) => ReasonReact.reactElement=?,
76-
~renderSectionFooter: section('item) => ReasonReact.reactElement=?,
81+
~renderSectionHeader: renderAccessoryView('item)=?,
82+
~renderSectionFooter: renderAccessoryView('item)=?,
7783
~stickySectionHeadersEnabled: bool=?,
7884
array(ReasonReact.reactElement)
7985
) =>

0 commit comments

Comments
 (0)