Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change class component to function component #6451

merged 3 commits into from Mar 11, 2019


Copy link

commented Feb 18, 2019

No description provided.


This comment has been minimized.

Copy link
Contributor Author

commented Feb 19, 2019

Should we use named export in TypeScript?
Why we use default export in almost all codes of react doc?

@cassiozen cassiozen referenced this pull request Feb 28, 2019


Roadmap for version 3.0 #6475

@iansu iansu self-assigned this Feb 28, 2019

@iansu iansu added this to the 3.0 milestone Feb 28, 2019

@iansu iansu added this to In progress in v3 via automation Feb 28, 2019

Show resolved Hide resolved packages/react-scripts/template-typescript/src/App.tsx Outdated
Show resolved Hide resolved packages/react-scripts/template/src/App.js Outdated
Update packages/react-scripts/template/src/App.js
Co-Authored-By: xiaoxiangmoe <>
Update packages/react-scripts/template-typescript/src/App.tsx
Co-Authored-By: xiaoxiangmoe <>
@@ -1,28 +1,26 @@
import React, { Component } from 'react';
import * as React from 'react';

This comment has been minimized.

Copy link

denisw Mar 1, 2019

Wouldn't import React, { FC } from 'react'; be more consistent in spirit to the current class-based version?

This comment has been minimized.

Copy link

xiaoxiangmoe Mar 6, 2019

Author Contributor

@denisw In TypeScript Doc it write:

import * as React from "react";

Should we use named export rather than default export?

This comment has been minimized.

Copy link

denisw Mar 6, 2019

Yes, import * as React is what you would need to do by default, but create-react-app's TypeScript configuration has allowSyntheticDefaultImports option enabled. From the documentation:

Allow default imports from modules with no default export. This does not affect code emit, just typechecking.

As the code emit part is taken care of by Babel here, import React "just works" the same way it does for the JavaScript setup.

@iansu iansu closed this Mar 11, 2019

v3 automation moved this from In progress to Done Mar 11, 2019

@iansu iansu reopened this Mar 11, 2019

v3 automation moved this from Done to In progress Mar 11, 2019

@iansu iansu merged commit e4fdac2 into facebook:master Mar 11, 2019

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
netlify/create-react-app/deploy-preview Docs deploy preview succeeded

v3 automation moved this from In progress to Done Mar 11, 2019


This comment has been minimized.

Copy link

commented Mar 11, 2019


JoviDeCroock added a commit to JoviDeCroock/create-react-app that referenced this pull request Mar 15, 2019

Merge branch 'masterd' into feat/modern-build
* masterd: (24 commits)
  Add TypeScript linting support (facebook#6513)
  Support React Hooks (facebook#5602) (facebook#5997)
  Support browserslist in @babel/preset-env (facebook#6608)
  Add empty mock for http2 (facebook#5686)
  Add note about npx caching (facebook#6374)
  change named import into default import (facebook#6625)
  Stage files for commit after ejecting (facebook#5960)
  Upgrade dependencies (facebook#6614)
  Make compiler variable const instead of let (facebook#6621)
  Type check JSON files (facebook#6615)
  Change class components to functional components in templates (facebook#6451)
  Convert JSON.stringify \n to os.EOL when writing tsconfig.json (facebook#6610)
  Update html-webpack-plugin (facebook#6361)
  Enable click to go to error in console for TypeScript (facebook#6502)
  Update webpack-dev-server to 3.2.1 (facebook#6483)
  [docs] revert removal of newlines from html (facebook#6386)
  Prepare 2.1.8 release
  Reapply "Speed up TypeScript v2 (facebook#6406)" (facebook#6586)

# Conflicts:
#	packages/babel-preset-react-app/create.js
#	packages/react-scripts/scripts/build.js

@lock lock bot locked and limited conversation to collaborators Mar 16, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.