javascript IsAuthenticated w / PropTypes的比较
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript IsAuthenticated w / PropTypes的比较相关的知识,希望对你有一定的参考价值。
import PropTypes from 'prop-types'
import React from 'react'
import { ReduxConnection } from '@ghadyani-framework/redux-components'
import { authInfoSelector } from '~/redux/auth/selectors'
const propTypes = {
children: PropTypes.node.isRequired,
}
const IsAuthenticated = ({
children,
}) => (
<ReduxConnection selector={authInfoSelector}>
{({
hasReceivedAuthInfo,
isAuthenticated,
}) => (
hasReceivedAuthInfo
&& isAuthenticated
&& children
)}
</ReduxConnection>
)
IsAuthenticated
.propTypes = propTypes
export default IsAuthenticated
import PropTypes from 'prop-types'
import React from 'react'
import { connect } from 'react-redux'
import { authInfoSelector } from '~/redux/auth/selectors'
const propTypes = {
children: PropTypes.node.isRequired,
hasReceivedAuthInfo: PropTypes.bool.isRequired,
isAuthenticated: PropTypes.bool.isRequired,
}
export const IsAuthenticated = ({
children,
hasReceivedAuthInfo,
isAuthenticated,
}) => ({
hasReceivedAuthInfo
&& isAuthenticated
&& children
)
IsAuthenticated
.propTypes = propTypes
export default (
connect(
authInfoSelector
)(
IsAuthenticated
)
)
以上是关于javascript IsAuthenticated w / PropTypes的比较的主要内容,如果未能解决你的问题,请参考以下文章
JavaScript介绍
javascript的题。
javascript JavaScript isset()等效: - JavaScript
JavaScript 使用JavaScript更改CSS(JavaScript)
JavaScript之基础-1 JavaScript(概述基础语法)
前端基础-JavaScript的基本概述和语法