microsoft / TypeScript-React-Starter

A starter template for TypeScript and React with a detailed README describing how to use the two together.
MIT License
11.09k stars 1.21k forks source link

Code style in tutorial, unused exports #154

Open vnglst opened 6 years ago

vnglst commented 6 years ago

I've got a question about the following example code in the Readme:

// src/containers/Hello.tsx

import Hello from '../components/Hello';
import * as actions from '../actions/';
import { StoreState } from '../types/index';
import { connect, Dispatch } from 'react-redux';

export function mapStateToProps({ enthusiasmLevel, languageName }: StoreState) {
  return {
    enthusiasmLevel,
    name: languageName,
  }
}

export function mapDispatchToProps(dispatch: Dispatch<actions.EnthusiasmAction>) {
  return {
    onIncrement: () => dispatch(actions.incrementEnthusiasm()),
    onDecrement: () => dispatch(actions.decrementEnthusiasm()),
  }
}

export default connect(mapStateToProps, mapDispatchToProps)(Hello);

I don't think mapStateToProps and mapDispatchToProps should be exported in this case (see for instance the official redux docs: https://github.com/reduxjs/react-redux/blob/master/docs/api.md)

Or is there a particular reason the export these functions in this case?

If not, I'll be glad to create a PR for this!

Great tutorials btw, it really helped me to get started quickly with the TypeScript & Redux combo. 🎊