拆分 ui 组件遇到的问题
来源:7-6 使用 React-Redux 进行应用数据的管理
慕少0974861
2019-07-04
###报错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);
`
1回答
-
慕少0974861
提问者
2019-07-04
已经解决。 是app 组件 写成了纯ui 组件, 在index 中使用的标签形式报的错
012019-07-07
相似问题