Skip to content

Commit 03ae982

Browse files
committed
change function to anonymous function
1 parent ab00794 commit 03ae982

40 files changed

+163
-116
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ import SubTitle from 'components/SubTitle';
7676
import UserList from 'components/UserList';
7777
import { fetchUsers } from 'actions/user';
7878

79-
function HomePage(props) {
79+
const HomePage = (props) => {
8080
const {
8181
state: {
8282
user: { userList },
@@ -91,7 +91,7 @@ function HomePage(props) {
9191
<UserList userList={userList} />
9292
</>
9393
);
94-
}
94+
};
9595

9696
HomePage.loadData = async (ctx) => {
9797
const {

src/actions/ui.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
export function openMenu() {
1+
export const openMenu = () => {
22
return (dispatch) => {
33
dispatch({ type: 'OPEN_MENU' });
44
};
5-
}
6-
export function closeMenu() {
5+
};
6+
export const closeMenu = () => {
77
return (dispatch) => {
88
dispatch({ type: 'CLOSE_MENU' });
99
};
10-
}
11-
export function showError(error) {
10+
};
11+
export const showError = (error) => {
1212
return (dispatch) => {
1313
dispatch({
1414
type: 'SHOW_ERROR',
@@ -17,9 +17,9 @@ export function showError(error) {
1717
},
1818
});
1919
};
20-
}
21-
export function hideError() {
20+
};
21+
export const hideError = () => {
2222
return (dispatch) => {
2323
dispatch({ type: 'HIDE_ERROR' });
2424
};
25-
}
25+
};

src/actions/user.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import axios from 'axios';
22

3-
export function fetchUser(id) {
3+
export const fetchUser = (id) => {
44
return (dispatch) =>
55
axios
66
.get(`https://jsonplaceholder.typicode.com/users/${id}`)
@@ -14,8 +14,8 @@ export function fetchUser(id) {
1414
// eslint-disable-next-line no-console
1515
console.error(err);
1616
});
17-
}
18-
export function fetchUsers() {
17+
};
18+
export const fetchUsers = () => {
1919
return (dispatch) =>
2020
axios
2121
.get('https://jsonplaceholder.typicode.com/users')
@@ -29,4 +29,4 @@ export function fetchUsers() {
2929
// eslint-disable-next-line no-console
3030
console.error(err);
3131
});
32-
}
32+
};

src/components/App/index.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -85,18 +85,18 @@ class App extends React.PureComponent {
8585
);
8686
}
8787
}
88-
function mapStateToProps(state) {
88+
const mapStateToProps = (state) => {
8989
return { state };
90-
}
91-
function mapDispatchToProps() {
90+
};
91+
const mapDispatchToProps = () => {
9292
return (dispatch) => ({
9393
dispatch,
9494
actions: {
9595
userActions: bindActionCreators(userActions, dispatch),
9696
uiActions: bindActionCreators(uiActions, dispatch),
9797
},
9898
});
99-
}
99+
};
100100

101101
const enhancers = [
102102
withExtendRouter,

src/components/Container/index.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ const ContainerUI = styled.div`
77
min-height: 100vh;
88
`;
99

10-
export default function Container(props) {
10+
const Container = (props) => {
1111
const { children } = props;
1212

1313
return <ContainerUI>{children}</ContainerUI>;
14-
}
14+
};
15+
16+
export default Container;

src/components/Error/index.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const ErrorUI = styled.div`
2424
animation: ${flash} 4s ease;
2525
`;
2626

27-
export default function Error(props) {
27+
const Error = (props) => {
2828
const { hideError, children } = props;
2929

3030
return (
@@ -36,4 +36,6 @@ export default function Error(props) {
3636
{children}
3737
</ErrorUI>
3838
);
39-
}
39+
};
40+
41+
export default Error;

src/components/Footer/index.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ const FooterUI = styled.div`
1616
line-height: 32px;
1717
`;
1818

19-
export default function Footer() {
19+
const Footer = () => {
2020
return <FooterUI>© 2018 osamu38</FooterUI>;
21-
}
21+
};
22+
23+
export default Footer;

src/components/Header/index.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const StyledOctIcon = styled(OctIcon)`
3434
margin-right: 12px;
3535
`;
3636

37-
export default function Header(props) {
37+
const Header = (props) => {
3838
const { isOpenMenu, openMenu, closeMenu } = props;
3939

4040
return (
@@ -55,4 +55,6 @@ export default function Header(props) {
5555
</HeaderUI>
5656
</HeaderContainer>
5757
);
58-
}
58+
};
59+
60+
export default Header;

src/components/Logo/index.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ const LogoUI = styled.a`
1111
line-height: 32px;
1212
`;
1313

14-
export default function Logo() {
14+
const Logo = () => {
1515
return (
1616
<PreloadLink href={endpoint.home}>
1717
<LogoUI>React SSR Starter</LogoUI>
1818
</PreloadLink>
1919
);
20-
}
20+
};
21+
22+
export default Logo;

src/components/Main/index.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ const MainUI = styled.div`
99
max-width: ${sizes.width.main + spaces.main * 2}px;
1010
`;
1111

12-
export default function Main(props) {
12+
const Main = (props) => {
1313
const { children } = props;
1414

1515
return <MainUI>{children}</MainUI>;
16-
}
16+
};
17+
18+
export default Main;

src/components/Menu/index.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const MenuLinkList = [
4242
},
4343
];
4444

45-
export default function Menu(props) {
45+
const Menu = (props) => {
4646
const { isOpenMenu } = props;
4747

4848
return isOpenMenu ? (
@@ -54,4 +54,6 @@ export default function Menu(props) {
5454
))}
5555
</MenuUI>
5656
) : null;
57-
}
57+
};
58+
59+
export default Menu;

src/components/MenuIcon/index.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const MenuIconUI = styled.img`
99
width: 32px;
1010
`;
1111

12-
export default function MenuIcon(props) {
12+
const MenuIcon = (props) => {
1313
const { isOpenMenu, openMenu, closeMenu } = props;
1414

1515
return (
@@ -25,4 +25,6 @@ export default function MenuIcon(props) {
2525
<MenuIconUI src="/static/images/svg/menu-icon.svg" alt="menu-icon" />
2626
</MenuIconWrapper>
2727
);
28-
}
28+
};
29+
30+
export default MenuIcon;

src/components/OctIcon/index.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22

3-
export default function OctIcon(props) {
3+
const OctIcon = (props) => {
44
const { className } = props;
55

66
return (
@@ -13,4 +13,6 @@ export default function OctIcon(props) {
1313
<img src="/static/images/svg/oct-icon.svg" alt="oct-icon" />
1414
</a>
1515
);
16-
}
16+
};
17+
18+
export default OctIcon;

src/components/PreloadLink/index.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ import { connect } from 'react-redux';
44
import withExtendRouter from 'components/withExtendRouter';
55
import customPush from 'utils/customPush';
66

7-
function mapStateToProps(state) {
7+
const mapStateToProps = (state) => {
88
return { state };
9-
}
10-
function mapDispatchToProps() {
9+
};
10+
const mapDispatchToProps = () => {
1111
return (dispatch) => ({
1212
dispatch,
1313
});
14-
}
14+
};
1515

16-
function PreloadLink(props) {
16+
const PreloadLink = (props) => {
1717
const {
1818
href,
1919
children,
@@ -29,7 +29,7 @@ function PreloadLink(props) {
2929
await customPush(href, push, dispatch, state);
3030
},
3131
});
32-
}
32+
};
3333

3434
const enhancers = [
3535
withExtendRouter,

src/components/StackList/index.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ const stackData = [
9090
},
9191
];
9292

93-
export default function StackList() {
93+
const StackList = () => {
9494
return (
9595
<StackListUI>
9696
{stackData.map((item, i) => (
@@ -102,4 +102,6 @@ export default function StackList() {
102102
))}
103103
</StackListUI>
104104
);
105-
}
105+
};
106+
107+
export default StackList;

src/components/SubTitle/index.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ const SubTitleUI = styled.div`
99
color: ${colors.darkGray};
1010
`;
1111

12-
export default function SubTitle(props) {
12+
const SubTitle = (props) => {
1313
const { children } = props;
1414

1515
return <SubTitleUI>{children}</SubTitleUI>;
16-
}
16+
};
17+
18+
export default SubTitle;

src/components/Title/index.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ const TitleUI = styled.h1`
99
color: ${colors.accent};
1010
`;
1111

12-
export default function Title(props) {
12+
const Title = (props) => {
1313
const { children } = props;
1414

1515
return <TitleUI>{children}</TitleUI>;
16-
}
16+
};
17+
18+
export default Title;

src/components/UserDetail/index.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const UserDetailInner = styled.div`
1212
border: 1px ${colors.superLightGray} solid;
1313
`;
1414

15-
export default function UserDetail(props) {
15+
const UserDetail = (props) => {
1616
const {
1717
user: {
1818
id,
@@ -55,4 +55,6 @@ export default function UserDetail(props) {
5555
</UserDetailInner>
5656
</UserDetailUI>
5757
);
58-
}
58+
};
59+
60+
export default UserDetail;

src/components/UserList/index.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const UserListLink = styled.a`
6060
}
6161
`;
6262

63-
export default function UserList(props) {
63+
const UserList = (props) => {
6464
const { userList } = props;
6565

6666
return (
@@ -74,4 +74,6 @@ export default function UserList(props) {
7474
))}
7575
</UserListUI>
7676
);
77-
}
77+
};
78+
79+
export default UserList;

src/components/withExtendRouter/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import { withRouter } from 'react-router-dom';
33
import { parse } from 'query-string';
44

5-
function withExtendRouter(Component) {
5+
const withExtendRouter = (Component) => {
66
const HOC = (props) => {
77
const { location } = props;
88
const { search } = location;
@@ -13,6 +13,6 @@ function withExtendRouter(Component) {
1313
return <Component {...props} location={location} />;
1414
};
1515
return withRouter(HOC);
16-
}
16+
};
1717

1818
export default withExtendRouter;

src/pages/about/index.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Title from 'components/Title';
44
import SubTitle from 'components/SubTitle';
55
import StackList from 'components/StackList';
66

7-
export default function AboutPage() {
7+
const AboutPage = () => {
88
return (
99
<>
1010
<Helmet title="About" />
@@ -13,4 +13,6 @@ export default function AboutPage() {
1313
<StackList />
1414
</>
1515
);
16-
}
16+
};
17+
18+
export default AboutPage;

src/pages/home/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import SubTitle from 'components/SubTitle';
55
import UserList from 'components/UserList';
66
import { fetchUsers } from 'actions/user';
77

8-
function HomePage(props) {
8+
const HomePage = (props) => {
99
const {
1010
state: {
1111
user: { userList },
@@ -20,7 +20,7 @@ function HomePage(props) {
2020
<UserList userList={userList} />
2121
</>
2222
);
23-
}
23+
};
2424

2525
HomePage.loadData = (ctx) => {
2626
const {

0 commit comments

Comments
 (0)