Skip to content

Commit 12da7b1

Browse files
committed
Merge pull request #8 from matijagaspar/fix-server-side-rendering
Fix server side rendering
2 parents f12ee3a + 7664ec9 commit 12da7b1

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/QueueAnim.jsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
import React, { createElement, cloneElement } from 'react';
22
import { findDOMNode } from 'react-dom';
3-
import velocity from 'velocity-animate';
3+
4+
let velocity;
5+
if ( typeof document !== 'undefined' && typeof window !== 'undefined' ) {
6+
// only load velocity on the client
7+
velocity = require('velocity-animate');
8+
} else {
9+
// provide a velocity stub for the server
10+
velocity = function velocityServerDummy() {
11+
const callback = arguments[arguments.length - 1];
12+
// call after stack flushes
13+
// in case you app depends on the asyncron nature of this function
14+
setImmediate(function() { callback(); });
15+
};
16+
}
17+
418
import {
519
toArrayChildren,
620
findChildInChildrenByKey,

0 commit comments

Comments
 (0)