diff --git a/package.json b/package.json index 7818ae6..7a68bf7 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "measure-scrollbar": "^0.1.0" }, "peerDependencies": { - "react": "^0.14.0 || ^15.0.0-0" + "react": "^0.14.0 || ^15.0.0-0 || ^16.0.0" }, "devDependencies": { "babel-cli": "^6.26.0", @@ -35,7 +35,7 @@ "babel-plugin-transform-runtime": "^6.23.0", "babel-preset-es2015": "6.6.0", "babel-preset-react": "6.5.0", - "babel-runtime": "^6.23.0", + "babel-runtime": "^6.26.0", "emoji-datasource": "^3.0.0", "emojilib": "^2.2.1", "inflection": "1.10.0", @@ -46,11 +46,11 @@ "karma-jasmine": "^1.1.0", "karma-webpack": "^2.0.2", "mkdirp": "0.5.1", - "prop-types": "^15.5.8", - "react": "^15.5.4", - "react-dom": "^15.5.4", + "prop-types": "^15.6.0", + "react": "^16.0.0", + "react-dom": "^16.0.0", "rimraf": "2.5.2", - "size-limit": "^0.11.1", + "size-limit": "^0.11.4", "svg-jsx-loader": "^0.0.16", "webpack": "1.12.14" }, diff --git a/src/components/category.js b/src/components/category.js index 37843e6..a55dd12 100644 --- a/src/components/category.js +++ b/src/components/category.js @@ -6,8 +6,6 @@ import { Emoji } from '.' export default class Category extends React.Component { componentDidMount() { - this.container = this.refs.container - this.label = this.refs.label this.parent = this.container.parentNode this.margin = 0 @@ -105,6 +103,14 @@ export default class Category extends React.Component { this.container.style.display = display } + setContainerRef(c) { + this.container = c + } + + setLabelRef(c) { + this.label = c + } + render() { var { name, hasStickyPosition, emojiProps, i18n } = this.props, emojis = this.getEmojis(), @@ -128,9 +134,9 @@ export default class Category extends React.Component { } } - return
+ return
- {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
-
+
{this.getCategories().map((category, i) => { return