1- import React , { useEffect , useState } from "react" ;
1+ import React , { useEffect , useRef , useState } from "react" ;
22import PT from "prop-types" ;
33import { connect } from "react-redux" ;
44import Listing from "./Listing" ;
@@ -26,7 +26,17 @@ const Challenges = ({
2626 recommendedChallenges,
2727 initialized,
2828 updateQuery,
29+ userLoggedIn,
30+ isLoggedIn,
31+ tags,
2932} ) => {
33+ const latestPropsRef = useRef ( null ) ;
34+ latestPropsRef . current = { userLoggedIn } ;
35+
36+ useEffect ( ( ) => {
37+ latestPropsRef . current . userLoggedIn ( ) ;
38+ } , [ ] ) ;
39+
3040 const BUCKET_OPEN_FOR_REGISTRATION = constants . FILTER_BUCKETS [ 1 ] ;
3141 const isRecommended = recommended && bucket === BUCKET_OPEN_FOR_REGISTRATION ;
3242 const sortByValue = isRecommended
@@ -75,7 +85,9 @@ const Challenges = ({
7585 updateQuery ( filterChange ) ;
7686 } }
7787 bucket = { bucket }
88+ tags = { tags }
7889 sortByLabels = { sortByLabels }
90+ isLoggedIn = { isLoggedIn }
7991 />
8092 </ >
8193 ) }
@@ -98,6 +110,8 @@ Challenges.propTypes = {
98110 recommendedChallenges : PT . arrayOf ( PT . shape ( ) ) ,
99111 initialized : PT . bool ,
100112 updateQuery : PT . func ,
113+ isLoggedIn : PT . bool ,
114+ tags : PT . arrayOf ( PT . string ) ,
101115} ;
102116
103117const mapStateToProps = ( state ) => ( {
@@ -114,11 +128,14 @@ const mapStateToProps = (state) => ({
114128 recommended : state . filter . challenge . recommended ,
115129 recommendedChallenges : state . challenges . recommendedChallenges ,
116130 initialized : state . challenges . initialized ,
131+ isLoggedIn : state . lookup . isLoggedIn ,
132+ tags : state . filter . challenge . tags ,
117133} ) ;
118134
119135const mapDispatchToProps = {
120136 updateFilter : actions . filter . updateFilter ,
121137 updateQuery : actions . filter . updateChallengeQuery ,
138+ userLoggedIn : actions . lookup . isLoggedIn ,
122139} ;
123140
124141const mergeProps = ( stateProps , dispatchProps , ownProps ) => ( {
0 commit comments