mirror of
https://github.com/zhigang1992/create-react-app.git
synced 2026-01-12 17:12:59 +08:00
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.
This commit is contained in:
@@ -51,12 +51,15 @@ One way to add SVG files was described in the section above. You can also import
|
||||
|
||||
```js
|
||||
import { ReactComponent as Logo } from './logo.svg';
|
||||
const App = () => (
|
||||
<div>
|
||||
{/* Logo is an actual React component */}
|
||||
<Logo />
|
||||
</div>
|
||||
);
|
||||
|
||||
function App() {
|
||||
return (
|
||||
<div>
|
||||
{/* Logo is an actual React component */}
|
||||
<Logo />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
This is handy if you don't want to load SVG as a separate file. Don't forget the curly braces in the import! The `ReactComponent` import name is significant and tells Create React App that you want a React component that renders an SVG, rather than its filename.
|
||||
|
||||
@@ -2,7 +2,7 @@ import React from 'react';
|
||||
import logo from './logo.svg';
|
||||
import './App.css';
|
||||
|
||||
const App = () => {
|
||||
function App() {
|
||||
return (
|
||||
<div className="App">
|
||||
<header className="App-header">
|
||||
|
||||
Reference in New Issue
Block a user