我有以下功能组件,我有兴趣了解如何将其更改为branch
增强组件,而不是if
声明。
import React from 'react'
import PropTypes from 'prop-types'
import { Button, Icon, Label } from 'semantic-ui-react'
import { Link } from 'react-router-dom'
import { setPropTypes, branch } from 'recompose'
const LoginOrMiniProfile = ({presence}) => {
if (presence.account) {
return (
<Link to='/profile'>
<Label>
<Icon name='user circle outline' />
{presence.account.firstName}
</Label>
</Link>
)
} else {
return (
<div>
<Button primary className={`login ${presence.loading && 'loading'}`}>Signup</Button>
<Button className={`login ${presence.loading && 'loading'}`}>Login</Button>
</div>
)
}
}
export default setPropTypes({
prensence: PropTypes.object.isRequired
})(LoginOrMiniProfile)
对于奖励积分,如何使用 Recompose 访问和更改presence
Redux 商店?