I was trying to comprehend this code on github
Here they programmer have used something like this
constructor(props) {
super(props);
this.actions = bindActionCreators(Actions, this.props.dispatch);
}
Question 1: Here, this.actions = bindActionCreators(Actions, this.props.dispatch); doesn't make sense to me
Also, This isn't primary question but from where I learned React-redux, we used to connect component like this
export default connect(mapStateToProps,
{fetchCoin,
updateCrypto,
CurrencyRate,
CurrencyState
})(cryptoTicker);
In the above code Snippet the programmer have done something like this
@connect(state => {
return {
score: state.game.get("score"),
result: state.game.get("result")
};
})
Question 2: ** Which again sort of looks alien to me (like I have few months of experience using js but this is the first time I am encountering **@) So can someone please explain me what is @ in general in JS?
And lastly he have declared two functions which are being called onclick after return statement of class
_handleNewGame = () => {
this.actions.initGame();
}
/**
* Save the current game`s state.
*/
_handleSaveGame = () => {
this.actions.saveGame();
}
Now Since I am still relatively new to JS and react, I have two questions for this part
Question 3: Can we create a function inside a class after return and render? If yes then wouldn't it have been a good practise (in general) to create a function before render where all the other functions are declared?