Skip to content

Commit

Permalink
fix window is not defined (alibaba#312)
Browse files Browse the repository at this point in the history
* fix(globalThis): fix ReferenceError

ReferenceError: self is not defined
alibaba#308

* fix(@uform/next): fix moveto window is not defined
  • Loading branch information
hero-guo authored and anyuxuan committed Nov 14, 2019
1 parent f6d93f1 commit e109a9f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 2 additions & 4 deletions packages/antd/src/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ import React from 'react'
import { Select as AntSelect, Icon } from 'antd'
import ReactDOM from 'react-dom'
import styled from 'styled-components'
import MoveTo from 'moveto'
import { isFn } from '@uform/utils'
import { IConnectProps, IFieldProps } from '@uform/react'

export * from '@uform/utils'

export interface ISelectProps {
Expand All @@ -16,7 +14,7 @@ export interface ISelectProps {
export interface IElement extends Element {
oldHTML?: string
}

const MoveTo = typeof window !== 'undefined' ? require('moveto') : null
const WrapSelect = styled(
class extends React.Component<ISelectProps> {
public render() {
Expand Down Expand Up @@ -239,7 +237,7 @@ export const transformDataSourceKey = (component, dataSourceKey) => {
}

export const moveTo = element => {
if (!element) {
if (!element || !MoveTo) {
return
}
if (element.scrollIntoView) {
Expand Down
4 changes: 2 additions & 2 deletions packages/next/src/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import React from 'react'
import { Select } from '@alifd/next'
import styled from 'styled-components'
import { isFn } from '@uform/utils'
import MoveTo from 'moveto'
import { IConnectProps, IFieldProps } from '@uform/react'

export * from '@uform/utils'

const MoveTo = typeof window !== 'undefined' ? require('moveto') : null
const Text = styled(props => {
let value
if (props.dataSource && props.dataSource.length) {
Expand Down Expand Up @@ -99,7 +99,7 @@ export const compose = (...args) => {
}

export const moveTo = element => {
if (!element) return
if (!element || !MoveTo) return
if (element.scrollIntoView) {
element.scrollIntoView({
behavior: 'smooth',
Expand Down

0 comments on commit e109a9f

Please sign in to comment.