texi rv texi rv - 12 days ago 4
HTML Question

Module build failed: SyntaxError: Unexpected token (11:16)


  • I am new to js

  • I am trying to move All of this logic in a helper function instead of in the render method

  • I am facing a syntax error.

  • can you guys tell me how to fix it.

  • providing my code below.




./src/components/first-time-tab/player-setup.jsx

Module build failed: SyntaxError: C:/workspace/fasg-sports-dashboard/src/components/first-time-tab/player-setup.jsx: Unexpected token (11:16)


9 | renderAccountTabContent() {
10 | return (
> 11 | let sportsStartDate = this.props.playerInfo.sportsStartDate;


Code

import React from 'react';
import {connect} from 'react-redux';
import moment from 'moment';

class AccountSetupTab extends React.Component {
renderAccountTabContent() {
return (
let sportsStartDate = this.props.playerInfo.sportsStartDate;
let renderData;

let now = moment().format('YYYY-MM-DD');
let past1Days = moment().subtract(1, 'days').format('YYYY-MM-DD');
let past2Days = moment().subtract(2, 'days').format('YYYY-MM-DD');
let past3Days = moment().subtract(3, 'days').format('YYYY-MM-DD');

if(sportsStartDate && sportsStartDate === now) {
renderData = 'We’re setting up your player and verifying the funds you’ve deposited. Don’t worry — it might take a couple of days for your player to reflect your balance.';
} else if(sportsStartDate && sportsStartDate === past1Days) {
renderData = "We’re setting up your player and verifying the funds you’ve deposited. Don’t worry — it might take a couple of days for your player to reflect your balance.";
} else if(sportsStartDate && sportsStartDate === past2Days) {
renderData = "We’re making some progress. See what’s happening today.";
} else if(sportsStartDate && sportsStartDate === past3Days) {
renderData = "We’ve put your money to work in your investment player.See what’s happening today.";
} else {
renderData = "Your new portfolio is a work in progress. See what’s happening today.";
}
);
}

render() {
/*let sportsStartDate = this.props.playerInfo.sportsStartDate;

let renderData;
let now = moment().format('YYYY-MM-DD');
let past1Days = moment().subtract(1, 'days').format('YYYY-MM-DD');
let past2Days = moment().subtract(2, 'days').format('YYYY-MM-DD');
let past3Days = moment().subtract(3, 'days').format('YYYY-MM-DD');

if(sportsStartDate && sportsStartDate === now) {
renderData = 'We’re setting up your player and verifying the funds you’ve deposited. Don’t worry — it might take a couple of days for your player to reflect your balance.';
} else if(sportsStartDate && sportsStartDate === past1Days) {
renderData = "We’re setting up your player and verifying the funds you’ve deposited. Don’t worry — it might take a couple of days for your player to reflect your balance.";
} else if(sportsStartDate && sportsStartDate === past2Days) {
renderData = "We’re making some progress. See what’s happening today.";
} else if(sportsStartDate && sportsStartDate === past3Days) {
renderData = "We’ve put your money to work in your investment player.See what’s happening today.";
} else {
renderData = "Your new portfolio is a work in progress. See what’s happening today.";
}*/
return(
<div className="sports-tab-content">
<p className="sports-large-text ft-day1 ft-day2 ft-day3">
{this.renderAccountTabContent()}
</p>
</div>
);
}
}

AccountSetupTab.propTypes = {
playerInfo: React.PropTypes.shape({
playerNumber: React.PropTypes.string,
addressLine1: React.PropTypes.string,
addressLine2: React.PropTypes.string,
addressLine3: React.PropTypes.string,
encId: React.PropTypes.string,
isIRA: React.PropTypes.boolean,
sportsStartDate: React.PropTypes.string,
managedProductActivationDate: React.PropTypes.string
}).isRequired,
};

/*function select(state) {
return {
playerInfo: state.playerInfo
};
}*/

//export default connect(select)(AccountSetupTab);

export default AccountSetupTab;

Answer

In your error, it shows you trying to return a variable assignment, not code. Put this line outside the return.

Try this ...

renderAccountTabContent() {
        let sportsStartDate = this.props.playerInfo.sportsStartDate;
        let renderData;

        let now = moment().format('YYYY-MM-DD');
        let past1Days = moment().subtract(1, 'days').format('YYYY-MM-DD');
        let past2Days = moment().subtract(2, 'days').format('YYYY-MM-DD');
        let past3Days = moment().subtract(3, 'days').format('YYYY-MM-DD');

        if(sportsStartDate && sportsStartDate === now) {
            renderData = 'We’re setting up your player and verifying the funds you’ve deposited. Don’t worry — it might take a couple of days for your player to reflect your balance.';
        } else if(sportsStartDate && sportsStartDate === past1Days) {
            renderData = "We’re setting up your player and verifying the funds you’ve deposited. Don’t worry — it might take a couple of days for your player to reflect your balance.";
        } else if(sportsStartDate && sportsStartDate === past2Days) {
            renderData = "We’re making some progress. See what’s happening today.";
        } else if(sportsStartDate && sportsStartDate === past3Days) {
            renderData = "We’ve put your money to work in your investment player.See what’s happening today.";
        } else {
            renderData = "Your new portfolio is a work in progress. See what’s happening today.";
        }

        return (
            renderData
        );
}
Comments