Add support for server-side rendering [Fix #7]
parent
29063f2f64
commit
f31a359f78
|
@ -29,9 +29,9 @@ export default class Category extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
shouldComponentUpdate(nextProps, nextState) {
|
shouldComponentUpdate(nextProps, nextState) {
|
||||||
var { name, perLine, emojis, emojiProps } = this.props,
|
var { name, perLine, hasStickyPosition, emojis, emojiProps } = this.props,
|
||||||
{ skin, size, sheetURL } = emojiProps,
|
{ skin, size, sheetURL } = emojiProps,
|
||||||
{ perLine: nextPerLine, emojis: nextEmojis, emojiProps: nextEmojiProps } = nextProps,
|
{ perLine: nextPerLine, hasStickyPosition: nextHasStickyPosition, emojis: nextEmojis, emojiProps: nextEmojiProps } = nextProps,
|
||||||
{ skin: nextSkin, size: nextSize, sheetURL: nextSheetURL } = nextEmojiProps,
|
{ skin: nextSkin, size: nextSize, sheetURL: nextSheetURL } = nextEmojiProps,
|
||||||
shouldUpdate = false
|
shouldUpdate = false
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ export default class Category extends React.Component {
|
||||||
shouldUpdate = !(emojis == nextEmojis)
|
shouldUpdate = !(emojis == nextEmojis)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (skin != nextSkin || size != nextSize || sheetURL != nextSheetURL) {
|
if (skin != nextSkin || size != nextSize || sheetURL != nextSheetURL || hasStickyPosition != nextHasStickyPosition) {
|
||||||
shouldUpdate = true
|
shouldUpdate = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,6 @@ const CATEGORIES = [
|
||||||
export default class Picker extends React.Component {
|
export default class Picker extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
this.testStickyPosition()
|
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
skin: store.get('skin') || props.skin,
|
skin: store.get('skin') || props.skin,
|
||||||
|
@ -35,6 +34,7 @@ export default class Picker extends React.Component {
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
if (this.state.firstRender) {
|
if (this.state.firstRender) {
|
||||||
|
this.testStickyPosition()
|
||||||
this.firstRenderTimeout = setTimeout(() => {
|
this.firstRenderTimeout = setTimeout(() => {
|
||||||
this.setState({ firstRender: false })
|
this.setState({ firstRender: false })
|
||||||
}, 60)
|
}, 60)
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
const NAMESPACE = 'emoji-mart'
|
const NAMESPACE = 'emoji-mart'
|
||||||
|
|
||||||
|
var isLocalStorageSupported = typeof window !== 'undefined' &&
|
||||||
|
'localStorage' in window
|
||||||
|
|
||||||
function update(state) {
|
function update(state) {
|
||||||
for (let key in state) {
|
for (let key in state) {
|
||||||
let value = state[key]
|
let value = state[key]
|
||||||
|
@ -8,13 +11,12 @@ function update(state) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function set(key, value) {
|
function set(key, value) {
|
||||||
if (!('localStorage' in window)) return
|
if (!isLocalStorageSupported) return
|
||||||
window.localStorage[`${NAMESPACE}.${key}`] = JSON.stringify(value)
|
window.localStorage[`${NAMESPACE}.${key}`] = JSON.stringify(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
function get(key) {
|
function get(key) {
|
||||||
if (!('localStorage' in window)) return
|
if (!isLocalStorageSupported) return
|
||||||
|
|
||||||
var value = window.localStorage[`${NAMESPACE}.${key}`]
|
var value = window.localStorage[`${NAMESPACE}.${key}`]
|
||||||
|
|
||||||
if (value) {
|
if (value) {
|
||||||
|
|
|
@ -5,7 +5,9 @@
|
||||||
|
|
||||||
// MIT license
|
// MIT license
|
||||||
|
|
||||||
(function() {
|
var isWindowAvailable = typeof window !== 'undefined'
|
||||||
|
|
||||||
|
isWindowAvailable && (function() {
|
||||||
var lastTime = 0;
|
var lastTime = 0;
|
||||||
var vendors = ['ms', 'moz', 'webkit', 'o'];
|
var vendors = ['ms', 'moz', 'webkit', 'o'];
|
||||||
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
|
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
|
||||||
|
|
Loading…
Reference in New Issue