From 70c3c18ca540fd09601ce0f577ee8fd39be0aee2 Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Wed, 13 Jan 2016 11:45:14 -0800 Subject: [PATCH] fix(newsletter): Checkbox refreshes properly when switching accounts --- src/components/newsletter-signup.cjsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/components/newsletter-signup.cjsx b/src/components/newsletter-signup.cjsx index cc5517148..6c9ad120b 100644 --- a/src/components/newsletter-signup.cjsx +++ b/src/components/newsletter-signup.cjsx @@ -13,14 +13,17 @@ class NewsletterSignup extends React.Component constructor: (@props) -> @state = {status: 'Pending'} + componentWillReceiveProps: (nextProps) => + @_onGetStatus(nextProps) + componentDidMount: => @_onGetStatus() - _onGetStatus: => + _onGetStatus: (props = @props) => @setState({status: 'Pending'}) EdgehillAPI.request method: 'GET' - path: @_path() + path: @_path(props) success: (status) => if status is 'Never Subscribed' @_onSubscribe() @@ -49,8 +52,8 @@ class NewsletterSignup extends React.Component error: => @setState({status: "Error"}) - _path: => - "/newsletter-subscription/#{encodeURIComponent(@props.emailAddress)}?name=#{encodeURIComponent(@props.name)}" + _path: (props = @props) => + "/newsletter-subscription/#{encodeURIComponent(props.emailAddress)}?name=#{encodeURIComponent(props.name)}" render: =>