Skip to content

Commit

Permalink
Add memoization section to README
Browse files Browse the repository at this point in the history
  • Loading branch information
erksch committed Mar 18, 2022
1 parent 3d68b5c commit 5595773
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function CityPicker() {

| Name | Type | Description |
| ---------------------- | ------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| options | any[] | Options to be displayed in the wheel picker. Options are rendered from top to bottom, meaning the first item in the options will be at the top and the last at the bottom. |
| options | string[] | Options to be displayed in the wheel picker. Options are rendered from top to bottom, meaning the first item in the options will be at the top and the last at the bottom. |
| selectedIndex | number | Index of the currently selected option. |
| onChange | (index: number) => void | Handler that is called when the selected option changes. |
| visibleRest | number | Amount of additional options that are visible in each direction. Default is 2, resulting in 5 visible options. |
Expand All @@ -58,3 +58,7 @@ function CityPicker() {
| opacityFunction | (x: number) => number | Function to determine the opacity of items based on their current distance to the center (which is x). Default is ![opacity equation](https://latex.codecogs.com/gif.latex?%5Csmall%20f%28x%29%20%3D%20%5Cleft%20%28%201%5Cover3%20%5Cright%20%29%20%5E%7Bx%7D) |
| decelerationRate | "normal", "fast", number | How quickly the underlying scroll view decelerates after the user lifts their finger. See the [ScrollView docs](https://facebook.github.io/react-native/docs/scrollview.html#decelerationrate). Default is "fast". |
| scrollEventThrottle | number | How often the scroll event will be fired while scrolling (as a time interval in ms). Impacts tradeof between scroll performance and tracking accuracy. See the [ScrollView docs](https://facebook.github.io/react-native/docs/scrollview.html#scrolleventthrottle). Default is 1. |

## Memoization

The individual items in the picker (`<WheelPickerItem />`) are [strictly memoized](https://github.com/erksch/react-native-wheely/blob/master/src/WheelPickerItem.tsx#L109-L114), meaning that they will not rerender after the initial render. Rerendering the picker items uncontrollably would lead to bad performance with large number of options. Item styles, animation functions and other parameters of items therefore must be static and changes to them after the initial render will have no effect.

0 comments on commit 5595773

Please sign in to comment.