请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

拆分 ui 组件遇到的问题

###报错
Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.
###header.js 的代码
`
import React from ‘react’;
import { connect } from ‘react-redux’;
import { CSSTransition } from ‘react-transition-group’

import {
HeaderWrapper,
Logo,
Nav,
NavItem,
SearchWrapper,
NavSearch,
Addition,
Button
} from ‘./style’;

const Header = props => {
const { focused, handleInputFocus, handleInputBlur} = props;
return (



首页
下载App
登陆





<NavSearch
className={focused ? ‘focused’ : ‘’}
onFocus={handleInputFocus}
onBlur={handleInputBlur}
/>

<i className={focused ? ‘focused iconfont’ : ‘iconfont’}>




写文章

注册


)
}

const mapStateToProps = state => {
return {
focused: state.focused
}
}

const mapDispatchToProps = dispatch => {
return {
handleInputFocus() {
const action = {
type: ‘search_focus’
}
dispatch(action)
},
handleInputBlur(){
const action = {
type: ‘search_focus’
}
dispatch(action)
}
}
}

export default connect(mapStateToProps, mapDispatchToProps)(Header);
`

正在回答 回答被采纳积分+3

1回答

提问者 慕少0974861 2019-07-04 21:15:05

已经解决。 是app 组件 写成了纯ui 组件, 在index 中使用的标签形式报的错  https://img1.sycdn.imooc.com//szimg/5d1dfba8000155f213240838.jpg

0 回复 有任何疑惑可以回复我~
  • Dell #1
    好的!
    回复 有任何疑惑可以回复我~ 2019-07-07 18:29:04
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信