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

Expose renderAheadOffset prop #37

Merged
merged 2 commits into from
May 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ npx babel-node scripts/compile.js
| `loggingFunction` | Logging function to be called when applicable.\* | function | none |
| `verboseLoggingFunction` | Same as loggingFunction but also provides strategy used to determine failed search | boolean | false |
| `filterFunctions` | Array of functions that are used to limit which emojis should be rendered. Each of this function will be invoked with single parameter being `emoji` data and if every function returns `true` for `emoji` then this emoji will be included and displayed.| Array(function) | [] |
| `renderAheadOffset` | Specify how many pixels in advance you want views to be rendered. Increasing this value can help reduce blanks (if any). However, making this low can improve performance if you're having issues with it (see [#36](https://github.com/sskhandek/react-native-emoji-input/issues/36)). Higher values also increase re-render compute | number | 1500 |
> \* When the search function yields this function is called. Additionally when the user clears the query box this function is called with the previous longest query since the last time the query box was empty. By default the function is called with one parameter, a string representing the query. If the verbose logging function parameter is set to true the function is called with a second parameter that is a string specifying why the function was called (either 'emptySearchResult' or 'longestPreviousQuery').

## Usage
Expand Down
10 changes: 6 additions & 4 deletions example/src/EmojiInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ class EmojiInput extends React.PureComponent {

render() {
const { selectedEmoji, offsetY } = this.state;
const { enableSearch, width } = this.props;
const { enableSearch, width, renderAheadOffset } = this.props;
return (
<View
style={{
Expand Down Expand Up @@ -509,7 +509,7 @@ class EmojiInput extends React.PureComponent {
)}
<RecyclerListView
style={{ flex: 1 }}
renderAheadOffset={1500}
renderAheadOffset={renderAheadOffset}
layoutProvider={this._layoutProvider}
dataProvider={this.state.dataProvider}
rowRenderer={this._rowRenderer}
Expand Down Expand Up @@ -643,7 +643,8 @@ EmojiInput.defaultProps = {
emojiFontSize: 40,
categoryFontSize: 20,
resetSearch: false,
filterFunctions: []
filterFunctions: [],
renderAheadOffset: 1500
};

EmojiInput.propTypes = {
Expand All @@ -668,7 +669,8 @@ EmojiInput.propTypes = {
numFrequentlyUsedEmoji: PropTypes.number,
defaultFrequentlyUsedEmoji: PropTypes.arrayOf(PropTypes.string),
resetSearch: PropTypes.bool,
filterFunctions: PropTypes.arrayOf(PropTypes.func)
filterFunctions: PropTypes.arrayOf(PropTypes.func),
renderAheadOffset: PropTypes.number
};

const styles = {
Expand Down
10 changes: 6 additions & 4 deletions src/EmojiInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ class EmojiInput extends React.PureComponent {

render() {
const { selectedEmoji, offsetY } = this.state;
const { enableSearch, width } = this.props;
const { enableSearch, width, renderAheadOffset } = this.props;
return (
<View
style={{
Expand Down Expand Up @@ -509,7 +509,7 @@ class EmojiInput extends React.PureComponent {
)}
<RecyclerListView
style={{ flex: 1 }}
renderAheadOffset={1500}
renderAheadOffset={renderAheadOffset}
layoutProvider={this._layoutProvider}
dataProvider={this.state.dataProvider}
rowRenderer={this._rowRenderer}
Expand Down Expand Up @@ -643,7 +643,8 @@ EmojiInput.defaultProps = {
emojiFontSize: 40,
categoryFontSize: 20,
resetSearch: false,
filterFunctions: []
filterFunctions: [],
renderAheadOffset: 1500
};

EmojiInput.propTypes = {
Expand All @@ -668,7 +669,8 @@ EmojiInput.propTypes = {
numFrequentlyUsedEmoji: PropTypes.number,
defaultFrequentlyUsedEmoji: PropTypes.arrayOf(PropTypes.string),
resetSearch: PropTypes.bool,
filterFunctions: PropTypes.arrayOf(PropTypes.func)
filterFunctions: PropTypes.arrayOf(PropTypes.func),
renderAheadOffset: PropTypes.number
};

const styles = {
Expand Down