- {i18n.categories[name.toLowerCase()]}
+ {i18n.categories[name.toLowerCase()]}
{emojis && emojis.map((emoji) =>
diff --git a/src/components/picker.js b/src/components/picker.js
index 4f87ddb..c43bea1 100644
--- a/src/components/picker.js
+++ b/src/components/picker.js
@@ -152,7 +152,7 @@ export default class Picker extends React.Component {
}
handleEmojiOver(emoji) {
- var { preview } = this.refs
+ var { preview } = this
// Use Array.prototype.find() when it is more widely supported.
const emojiData = CUSTOM_CATEGORY.emojis.filter(customEmoji => customEmoji.id === emoji.id)[0]
preview.setState({ emoji: Object.assign(emoji, emojiData) })
@@ -161,7 +161,7 @@ export default class Picker extends React.Component {
handleEmojiLeave(emoji) {
this.leaveTimeout = setTimeout(() => {
- var { preview } = this.refs
+ var { preview } = this
preview.setState({ emoji: null })
}, 16)
}
@@ -170,7 +170,7 @@ export default class Picker extends React.Component {
this.props.onClick(emoji, e)
if (!this.hideRecent) frequently.add(emoji)
- var component = this.refs['category-1']
+ var component = this.categoryRefs['category-1']
if (component) {
let maxMargin = component.maxMargin
component.forceUpdate()
@@ -199,7 +199,7 @@ export default class Picker extends React.Component {
handleScrollPaint() {
this.waitingForPaint = false
- if (!this.refs.scroll) {
+ if (!this.scroll) {
return
}
@@ -208,7 +208,7 @@ export default class Picker extends React.Component {
if (SEARCH_CATEGORY.emojis) {
activeCategory = SEARCH_CATEGORY
} else {
- var target = this.refs.scroll,
+ var target = this.scroll,
scrollTop = target.scrollTop,
scrollingDown = scrollTop > (this.scrollTop || 0),
minTop = 0
@@ -216,7 +216,7 @@ export default class Picker extends React.Component {
for (let i = 0, l = this.categories.length; i < l; i++) {
let ii = scrollingDown ? (this.categories.length - 1 - i) : i,
category = this.categories[ii],
- component = this.refs[`category-${ii}`]
+ component = this.categoryRefs[`category-${ii}`]
if (component) {
let active = component.handleScroll(scrollTop)
@@ -246,7 +246,7 @@ export default class Picker extends React.Component {
}
if (activeCategory) {
- let { anchors } = this.refs,
+ let { anchors } = this,
{ name: categoryName } = activeCategory
if (anchors.state.selected != categoryName) {
@@ -261,7 +261,7 @@ export default class Picker extends React.Component {
SEARCH_CATEGORY.emojis = emojis
for (let i = 0, l = this.categories.length; i < l; i++) {
- let component = this.refs[`category-${i}`]
+ let component = this.categoryRefs[`category-${i}`]
if (component && component.props.name != 'Search') {
let display = emojis ? 'none' : 'inherit'
@@ -270,13 +270,13 @@ export default class Picker extends React.Component {
}
this.forceUpdate()
- this.refs.scroll.scrollTop = 0
+ this.scroll.scrollTop = 0
this.handleScroll()
}
handleAnchorClick(category, i) {
- var component = this.refs[`category-${i}`],
- { scroll, anchors } = this.refs,
+ var component = this.categoryRefs[`category-${i}`],
+ { scroll, anchors } = this,
scrollToComponent = null
scrollToComponent = () => {
@@ -295,7 +295,7 @@ export default class Picker extends React.Component {
if (SEARCH_CATEGORY.emojis) {
this.handleSearch(null)
- this.refs.search.clear()
+ this.search.clear()
window.requestAnimationFrame(scrollToComponent)
} else {
@@ -312,12 +312,12 @@ export default class Picker extends React.Component {
updateCategoriesSize() {
for (let i = 0, l = this.categories.length; i < l; i++) {
- let component = this.refs[`category-${i}`]
+ let component = this.categoryRefs[`category-${i}`]
if (component) component.memoizeSize()
}
- if (this.refs.scroll) {
- let target = this.refs.scroll
+ if (this.scroll) {
+ let target = this.scroll
this.scrollHeight = target.scrollHeight
this.clientHeight = target.clientHeight
}
@@ -327,6 +327,30 @@ export default class Picker extends React.Component {
return this.state.firstRender ? this.categories.slice(0, 3) : this.categories
}
+ setAnchorsRef(c) {
+ this.anchors = c
+ }
+
+ setSearchRef(c) {
+ this.search = c
+ }
+
+ setPreviewRef(c) {
+ this.preview = c
+ }
+
+ setScrollRef(c) {
+ this.scroll = c
+ }
+
+ setCategoryRef(name, c) {
+ if (!this.categoryRefs) {
+ this.categoryRefs = {}
+ }
+
+ this.categoryRefs[name] = c
+ }
+
render() {
var { perLine, emojiSize, set, sheetSize, style, title, emoji, color, native, backgroundImageFn, emojisToShowFilter, include, exclude, autoFocus } = this.props,
{ skin } = this.state,
@@ -335,7 +359,7 @@ export default class Picker extends React.Component {
return