Skip to content

Commit

Permalink
fix: #76
Browse files Browse the repository at this point in the history
  • Loading branch information
MuYunyun committed Jan 29, 2021
1 parent f9e5a00 commit 3361a1e
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 18 deletions.
4 changes: 1 addition & 3 deletions packages/crd-seed/component/Affix/affix.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import * as React from 'react'
import { useState, useLayoutEffect, useRef } from 'react'
import { throttle } from './utils'

const { useState, useLayoutEffect, useRef } = React

const Affix = ({
offsetTop,
offsetBottom,
Expand Down
4 changes: 1 addition & 3 deletions packages/crd-seed/component/Icon/Icon.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import * as React from 'react'
import { useEffect } from 'react'
import cx from 'classnames'
import loadSprite from './loadSprite'
import styles from './style/index.less'

const { useEffect } = React

/* omit some props depends on arr */
const omit = (props, arr) =>
Object.keys(props)
Expand Down
4 changes: 2 additions & 2 deletions packages/crd-seed/component/Menu/Menu.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as React from 'react'
import { useState } from 'react'
import cx from 'classnames'
import MenuItem from './MenuItem'
import { SubMenu } from './SubMenu'
Expand All @@ -16,7 +16,7 @@ const Menu = ({
toggle,
}) => {
/* 存储 hover 状态的 key 值, 在垂直模式中需要根据 hover 的 key 值高亮父节点 */
const [hoverKey, setHoverKey] = React.useState('')
const [hoverKey, setHoverKey] = useState('')
const MenuContext = {
theme,
mode: 'inline',
Expand Down
12 changes: 6 additions & 6 deletions packages/crd-seed/component/Menu/SubMenu.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState, useRef, useLayoutEffect } from 'react'
import { useState, useRef, useLayoutEffect, Fragment, Children, cloneElement } from 'react'
import cx from 'classnames'
import Transition from './transition'
import { getMenuStyle } from './util'
Expand Down Expand Up @@ -55,17 +55,17 @@ function SubMenu({
*/
function isReactFragment(variableToInspect) {
if (variableToInspect.type) {
return variableToInspect.type === React.Fragment
return variableToInspect.type === Fragment
}
return variableToInspect === React.Fragment
return variableToInspect === Fragment
}

/* 行内模式下, 渲染子节点 */
const renderChild = (child) => {
return (
// eslint-disable-next-line quotes
<>
{React.Children.map(child || children, (reactNode) => {
{Children.map(child || children, (reactNode) => {
if (!reactNode || typeof reactNode !== 'object') {
return null
}
Expand All @@ -76,7 +76,7 @@ function SubMenu({
) {
return renderChild(childElement.props.children)
}
return React.cloneElement(childElement, {
return cloneElement(childElement, {
level: level + 1,
...childElement.props,
})
Expand Down Expand Up @@ -106,7 +106,7 @@ function SubMenu({
/* 判断 subMenu 是否被选中, 当子节点被选中时, 父节点也会被高亮;
同时在 vertical 模式时, 当子节点被 hover 时, 父节点也会被高亮; */
const judgeSubmenuSelect = (reactChildren) => {
const result = React.Children.toArray(reactChildren).some((reactNode) => {
const result = Children.toArray(reactChildren).some((reactNode) => {
if (!reactNode || typeof reactNode !== 'object') {
return false
}
Expand Down
4 changes: 1 addition & 3 deletions packages/crd-seed/component/Menu/context.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import * as React from 'react'

const { createContext, useContext } = React
import { createContext, useContext } from 'react'

const MenuContext = createContext(undefined)

Expand Down
2 changes: 1 addition & 1 deletion packages/scripts/src/conf/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = function (cmd) {
const loaders = []
loaders.push({
// Process JS with Babel.
test: /\.(js|jsx|mjs)$/,
test: /\.(js|jsx)$/,
exclude: paths.getExcludeFoldersRegExp.concat(/\.(cache)/),
use: [
{
Expand Down

0 comments on commit 3361a1e

Please sign in to comment.