Skip to content

Commit

Permalink
feat: add ssr support, close #2605
Browse files Browse the repository at this point in the history
  • Loading branch information
KgTong committed Jun 6, 2018
1 parent 4097fc2 commit 4965ba3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
7 changes: 7 additions & 0 deletions components/_util/exenv.tsx
@@ -0,0 +1,7 @@
export const canUseDOM = !!(
typeof window !== 'undefined' &&
window.document &&
window.document.createElement
);

export const IS_IOS = canUseDOM && /iphone|ipad|ipod/i.test(window.navigator.userAgent);
3 changes: 2 additions & 1 deletion components/input-item/CustomInput.tsx
Expand Up @@ -5,6 +5,7 @@ import { addClass, removeClass } from '../_util/class';
import CustomKeyboard from './CustomKeyboard';
import Portal from './Portal';
import { InputEventHandler } from './PropsType';
import { canUseDOM } from '../_util/exenv';

let instanceArr: any = [];
let customNumberKeyboard: CustomKeyboard | null = null;
Expand Down Expand Up @@ -311,7 +312,7 @@ class NumberInput extends React.Component<NumberInputProps, any> {
}

renderPortal() {
if (!IS_REACT_16) {
if (!IS_REACT_16 || !canUseDOM) {
return null;
}

Expand Down
3 changes: 1 addition & 2 deletions components/input-item/CustomKeyboard.tsx
Expand Up @@ -2,8 +2,7 @@ import classnames from 'classnames';
import React from 'react';
import TouchFeedback from 'rmc-feedback';
import { Omit } from '../_util/types';

const IS_IOS = /iphone|ipad|ipod/i.test(window.navigator.userAgent);
import { IS_IOS } from '../_util/exenv';

export type HTMLTableDataProps = Omit<
React.HTMLProps<HTMLTableDataCellElement>,
Expand Down

0 comments on commit 4965ba3

Please sign in to comment.