2483 Commits

Author SHA1 Message Date
Lewis Llobera
687c4ebf21 Change arrow functions to function declarations (#8412)
- The JavaScript template uses a function declaration to define the component, the TypeScript template and a page of the documentation used arrow functions. Changed it to use function declarations for consistency and readability.
2020-02-03 15:28:39 +01:00
Andrew Luca
1cbc6f7db6 feat(react-scripts): allow PUBLIC_URL in develoment mode (#7259)
Co-authored-by: Eric Clemmons <eric@smarterspam.com>
Co-authored-by: Alex Guerra <alex@heyimalex.com>
Co-authored-by: Kelly <kelly.milligan@gmail.com>

Co-authored-by: Eric Clemmons <eric@smarterspam.com>
Co-authored-by: Alex Guerra <alex@heyimalex.com>
Co-authored-by: Kelly <kelly.milligan@gmail.com>
2020-02-02 12:55:26 +01:00
Rohit Singhal
3190e4f4a9 Handle service worker error in Firefox (#8272)
* Handle service worker error in Firefox

See https://bugzilla.mozilla.org/show_bug.cgi?id=1429714 for more details.

* Update serviceWorker.js
2020-01-31 16:09:19 +01:00
Alex Brazier
0299c0e6e7 Add option to provide custom ssl certificates during development (#5845)
* Add option to provide custom SSL certificates when using HTTPS

* Update documentation with custom HTTPS certs

* Improve certificate validation and move to its own file

* Update https in development docs

Co-Authored-By: Brody McKee <mrmckeb@users.noreply.github.com>

* Add custom cert example to docs

* Rename https file and update error message

* Include original error message when custom ssl cert is invalid

* Add chalk to react-scripts dependencies

* Bump docs version to say that the new config will be available in 3.2.0

* Remove chalk dependency

* Update custom ssl version to 3.4.0 in docs

* Remove version from custom ssl certificate docs

Co-authored-by: Brody McKee <mrmckeb@users.noreply.github.com>
2020-01-31 13:36:06 +01:00
Grady Kuhnline
822422cebe Enable custom sockjs pathname for hot reloading server. (#7750)
* Enable custom sockjs pathname for hot reloading server.

* Update docusaurus/docs/advanced-configuration.md

Co-Authored-By: Brody McKee <mrmckeb@users.noreply.github.com>

* let WDS_SOCKET_PATH be undefined

* adding env variables for sockHost and sockPort options

Co-authored-by: Brody McKee <mrmckeb@users.noreply.github.com>
2020-01-31 13:07:56 +01:00
David Powell
cc985d0b00 Support JetBrains Rider IDE as an editor (#7948)
Rider is JetBrains .NET IDE, which supports the React plugin identically to other JetBrains IDEs such as Idea and WebStorm.
2020-01-31 13:04:14 +01:00
Łukasz Fiszer
84d8b143f3 Run git init before template dependencies are installed (#8282) 2020-01-31 12:59:15 +01:00
Kevin Pham
9233cafb05 Update public folder usage docs to clarify globals (#8299)
Added the relevant topic linked directly, instead of saying it's just in the next section.
Adjusted the text so it sounds more like a recommendation rather than a requirement.
The topic linked is basically explainer to how you'd reference it using the global window object and ways to avoid linter errors. Thus I used 'reference' to give users a hint of what it the linked page would be for.
2020-01-31 12:56:51 +01:00
Martin Litvaj
1959131423 Fix robots.txt for TS (#8403) 2020-01-31 12:55:05 +01:00
吕立青
0db04ecd8e setupTestFrameworkScriptFile is deprecated (#8390)
* setupTestFrameworkScriptFile is deprecated

__Note:_ `_setupTestFrameworkScriptFile_` _is deprecated in favor of_ `_setupFilesAfterEnv_`_.__

ref: https://jestjs.io/docs/en/configuration#setupfilesafterenv-array

* Update docusaurus/docs/running-tests.md

Co-Authored-By: Simen Bekkhus <sbekkhus91@gmail.com>

Co-authored-by: Simen Bekkhus <sbekkhus91@gmail.com>
2020-01-31 12:53:22 +01:00
Andrew Luca
325e599726 fix(test): force install npm in e2e-behaviour (#8402)
This will fix e2e-behaviour on macos

Related: https://github.com/npm/cli/issues/611#issuecomment-575287540
2020-01-31 12:52:29 +01:00
Matthew Curtis
d2de54b25c Wider Chromium support for openBrowser (#8367)
* Expands scope of openBrowser tab control

Adjust openChrome.applescript to allow manipulation of
other Chromium-based browsers (defaulting to Chrome).
Requires list of compatible browsers to try in openBrowser.js

* Fix typo

* Remove Safari
2020-01-31 09:53:29 +01:00
Christopher Button
d9e05f9ce5 Update commit message to use imperative mood (#8377)
Why:

* As per best practice:
  https://git.kernel.org/pub/scm/git/git.git/tree/Documentation/SubmittingPatches#n135

  See also:
  https://chris.beams.io/posts/git-commit/#imperative
2020-01-31 08:59:02 +01:00
Cassidy Williams
fb9745eb76 Make the PWA link point to the right place (#8379) 2020-01-31 08:57:26 +01:00
Ian Sutherland
d7c68420f7 Publish
- babel-plugin-named-asset-import@0.3.6
 - babel-preset-react-app@9.1.1
 - cra-template-typescript@1.0.1
 - cra-template@1.0.1
 - create-react-app@3.3.1
 - eslint-config-react-app@5.2.0
 - react-app-polyfill@1.0.6
 - react-dev-utils@10.1.0
 - react-error-overlay@6.0.5
 - react-scripts@3.3.1
cra-template@1.0.1 create-react-app@3.3.1 eslint-config-react-app@5.2.0 react-app-polyfill@1.0.6 react-dev-utils@10.1.0 react-error-overlay@6.0.5 react-scripts@3.3.1 babel-preset-react-app@9.1.1 cra-template-typescript@1.0.1 babel-plugin-named-asset-import@0.3.6 v3.3.1
2020-01-30 21:05:43 -07:00
Ian Sutherland
a7b8732faa Prepare 3.3.1 release 2020-01-30 20:45:34 -07:00
Hu Chen
4da41b490f docs: Add troubleshooting documentation on ENOSPC (#8380)
Co-authored-by: Ian Schmitz <ianschmitz@gmail.com>
2020-01-30 16:56:03 -08:00
Kanitkorn Sujautra
03018d7726 Update docs according to lint-staged v10 (#8394) 2020-01-30 16:39:22 -08:00
Joshua Pollak
6ee4e919d6 Add helpful message to the footer (#6548) 2020-01-30 16:22:48 -08:00
Tomoya Fujita
ed162a3c5e Add "Disallow:" to robots.txt (#8255) 2020-01-30 15:59:41 -08:00
Marius Craciunoiu
e530598f85 Fix sass importLoaders (#8281) 2020-01-30 15:50:01 -08:00
Alex James Vukovity
dd0df73d79 Remove outdated docs regarding vscode eslint extension and type… (#8307)
Co-authored-by: Ian Schmitz <ianschmitz@gmail.com>
2020-01-30 15:19:08 -08:00
Boyuan Xu
ca9c61e96c Update setting-up-your-editor.md (#8247)
`Auto Fix is enabled by default. Use the single string form.` warning is shown in `.vscode/settings.json` due to changes in vscode-eslint. 
As autoFix is set to default, object format in `eslint.validate` is deprecated.
2020-01-30 15:14:40 -08:00
Kevin Old
cafd602a87 Update custom template docs with instructions for testing custom template locally (#8092)
Co-authored-by: Ian Schmitz <ianschmitz@gmail.com>
2020-01-30 14:45:35 -08:00
Ian Schmitz
720d90bc88 Sync dependencies babel config (#8120) 2020-01-30 14:41:39 -08:00
Rasmus Nørskov
ddcb7d50ac Add titleProp to SVGR ReactComponent type definition (#8099) 2020-01-30 14:33:44 -08:00
Ian Schmitz
b855da5732 Remove outdated babel plugins (#8353)
Updates dependencies and removes babel plugins that are now covered by `@babel/preset-env`.

Co-authored-by: hdineen <hdineen@hubspot.com>
2020-01-30 14:18:09 -08:00
Vincent Semrau
4bf14fa665 Downgrade open from 7.0.0 to 6.4.0 (#8364) 2020-01-23 13:37:27 +01:00
Retsam
dada03574a Remove React.FC from Typescript template (#8177)
This removes `React.FC` from the base template for a Typescript project.

Long explanation for a small change: 

`React.FC` is unnecessary: it provides next to no benefits and has a few downsides.  (See below.)  I see a lot of beginners to TS+React using it, however, and I think that it's usage in this template is a contributing factor to that, as the prominence of this template makes it a de facto source of "best practice".  

### Downsides to React.FC/React.FunctionComponent

##### Provides an implicit definition of `children`

Defining a component with `React.FC` causes it to implicitly take `children` (of type `ReactNode`).  It means that all components accept children, even if they're not supposed to, allowing code like:

```ts
const App: React.FC = () => { /*... */ };
const Example = () => {
	<App><div>Unwanted children</div></App>
}
```

This isn't a run-time error, but it is a mistake and one that would be caught by Typescript if not for `React.FC`. 

##### Doesn't support generics.
I can define a generic component like:
```ts
type GenericComponentProps<T> = {
   prop: T
   callback: (t: T) => void
}
const GenericComponent = <T>(props: GenericComponentProps<T>) => {/*...*/}
```

But it's not possible when using `React.FC` - there's no way to preserve the unresolved generic `T` in the type returned by `React.FC`.

```ts
const GenericComponent: React.FC</* ??? */> = <T>(props: GenericComponentProps<T>) => {/*...*/}
```

##### Makes "component as namespace pattern" more awkward.
It's a somewhat popular pattern to use a component as a namespace for related components (usually children):

```jsx
<Select>
	<Select.Item />
</Select>
```

This is possible, but awkward, with `React.FC`:

```tsx
const  Select: React.FC<SelectProps> & { Item: React.FC<ItemProps> } = (props) => {/* ... */ }
Select.Item = (props) => { /*...*/ }
```

but "just works" without `React.FC`:

```tsx
const Select = (props: SelectProps) => {/* ... */}
Select.Item = (props) => { /*...*/ }
```

##### Doesn't work correctly with defaultProps

This is a fairly moot point as in both cases it's probably better to use ES6 default arguments, but...

```tsx
type  ComponentProps = { name: string; }

const  Component = ({ name }: ComponentProps) => (<div>
	{name.toUpperCase()} /* Safe since name is required */
</div>);
Component.defaultProps = { name: "John" };

const  Example = () => (<Component />) /* Safe to omit since name has a default value */
```
This compiles correctly.  Any approach with `React.FC` will be slightly wrong: either `React.FC<{name: string}>` will make the prop required by consumers, when it should be optional, or `React.FC<{name?: string}>` will cause `name.toUpperCase()` to be a type error.  There's no way to replicate the "internally required, externally optional" behavior which is desired.

##### It's as long, or longer than the alternative: (especially longer if you use `FunctionalComponent`):
Not a huge point, but it isn't even shorter to use `React.FC` 
```ts
const C1: React.FC<CProps> = (props) => { }
const C2 = (props: CProps) => {};
```

### Benefits of React.FC

##### Provides an explicit return type

The only benefit I really see to `React.FC` (unless you think that implicit `children` is a good thing) is that it specifies the return type, which catches mistakes like:

```ts
const Component = () => {
   return undefined; // components aren't allowed to return undefined, just `null`
}
```

In practice, I think this is fine, as it'll be caught as soon as you try to use it:

```ts
const Example = () => <Component />; // Error here, due to Component returning the wrong thing
```

But even with explicit type annotations, `React.FC` still isn't saving very much boilerplate:

```ts
const Component1 = (props: ComponentProps): ReactNode => { /*...*/ }
const Component2: FC<ComponentProps> = (props) => { /*...*/ }
```
2020-01-22 13:32:49 -08:00
Reece Dunham
a608c5affc Update Dependencies (#8324) 2020-01-21 14:46:01 -08:00
Evan Grim
f875bb0c84 Minor grammatical edit (#8293) 2020-01-16 11:25:28 -08:00
Tom Valorsa
94932bedc0 Allow additional package keys and add blacklist (#8082) (#8219) 2020-01-12 14:10:03 +02:00
Kai Hao
fa85f030de Support shorthand scoped templates (#8298) 2020-01-12 14:07:07 +02:00
Alex Guerra
c03bb366e0 Replace favicon in templates (#8194)
The old favicon was the same as the official react documentation, which is a minor annoyance during development when trying to find the tab you want. The new favicon is just the old with inverted colors.

Closes #7957
2019-12-30 13:53:00 -06:00
Sony AK
3f2037bb2a Little typo (#8212) 2019-12-20 13:55:58 +01:00
Andreas Cederström
88a543549b Bump babel-plugin-tester and fix breaking changes (#8171) 2019-12-19 10:52:19 +01:00
Brian Muenzenmeyer
18e56da3b7 fix: proactively append to .gitignore during init (#8028) 2019-12-18 20:42:55 +02:00
Alex Guerra
30eaab4ef2 Minor refactors in create-react-app (#8178)
- Remove templates version minimum stopgap.
- Replace indexOf with more idiomatic alternatives.
- Inline errorLogFilePatterns.
- Alphabetize validFiles.
- Simplify log file removal code.
- Move unconditional console.log() call outside of isSafe.
- Differentiate conflicting directories from files.
- Document yarn version special case.
- Inline printValidationResults.
- Standardize checkAppName output on failure.
- Add link for checkThatNpmCanReadCwd.

Functionally the code should be exactly the same.
2019-12-16 14:56:37 -06:00
Peet Goddard
1a13b594ae Update PWA docs links to point to template package (#8147) 2019-12-15 16:21:05 -05:00
Jerome De Leon
f31485567b Add package-runner note to readme (#8132)
* Add package-runner note to readme

* Add link to `yarn create`
2019-12-15 16:19:41 -05:00
Andreas Cederström
f26de73e64 Bump internal dependencies (#8176)
* Bump dependencies in react-dev-utils

* Bump dependencies in react-app-polyfill

* Bump dependencies in create-react-app

* Bump dependencies in react-error-overlay

* Bump dependencies in react-scripts

* Bump react
2019-12-14 06:33:53 +01:00
Ian Sutherland
ab2976f350 Add link to Netlify in README 2019-12-13 14:23:13 -05:00
Andreas Cederström
349a92a8c8 Bump chalk (#8164) 2019-12-13 20:02:04 +01:00
Andreas Cederström
9922275c14 Bump pkgUp (#8163) 2019-12-13 10:57:54 +01:00
Alex Guerra
ebcffdacdc Add current version and bin location to --info output (#8168)
Make the --info subcommand outuput the current version information and the location of the file being run. Our issue template tells users to provide the output of --info, so having the current version is incredibly helpful, especially since it doesn't necessarily match the globally installed version that envinfo outputs. Knowing the location helps us determine whether the running bin is globally installed or in the local node_modules.
2019-12-13 10:56:48 +01:00
Reece Dunham
8d1a4f2fce [Security] Update terser webpack plugin (#8102)
* security: update terser webpack plugin
2019-12-11 17:39:30 +01:00
Endi
1f1594d520 chore: update docusaurus & tweak site (#8111) 2019-12-10 15:42:30 -05:00
Vadzim
b8ff97be72 Fix typo in comment: ?. is right, not .? (#8124)
This is just a comment fix.

Actual optional chaining operator syntax is `?.`, not `.?`.
2019-12-09 14:09:06 -08:00
Wojciech Zieliński
53a48c40b3 Add slashes to WebSocket protocol URL (#8116) 2019-12-08 22:57:34 -08:00
Simon Donaldson
0327d8952a Fix CSS font-face minification (#8106) 2019-12-08 22:21:47 -08:00