From 128edd0a84b5e25c220e23b47dd5569b2bac4757 Mon Sep 17 00:00:00 2001 From: Todor Totev <51530311+TodorTotev@users.noreply.github.com> Date: Fri, 5 Jun 2020 19:00:10 +0300 Subject: [PATCH] [Examples] Refactor with-electron-typescript (#13802) Related to [11014](https://github.com/vercel/next.js/issues/11014). Removed getInitialProps in favor of getStaticProps and getServerSideProps. Refactored one of the components from class to functional. Removed redundant imports. Removed React.FC/FunctionComponent. Added two build files to gitignore. Let me know if you want something to be changed. --- .../renderer/components/Layout.tsx | 8 +-- .../renderer/components/List.tsx | 4 +- .../renderer/components/ListDetail.tsx | 4 +- .../renderer/components/ListItem.tsx | 4 +- .../renderer/pages/about.tsx | 3 +- .../renderer/pages/detail.tsx | 65 ++++++++++--------- .../renderer/pages/index.tsx | 4 +- .../renderer/pages/initial-props.tsx | 36 +++++----- 8 files changed, 64 insertions(+), 64 deletions(-) diff --git a/examples/with-electron-typescript/renderer/components/Layout.tsx b/examples/with-electron-typescript/renderer/components/Layout.tsx index b55cbb6afce0..a757f02c9020 100644 --- a/examples/with-electron-typescript/renderer/components/Layout.tsx +++ b/examples/with-electron-typescript/renderer/components/Layout.tsx @@ -1,15 +1,13 @@ -import * as React from 'react' +import React, { ReactNode } from 'react' import Link from 'next/link' import Head from 'next/head' type Props = { + children: ReactNode title?: string } -const Layout: React.FunctionComponent = ({ - children, - title = 'This is the default title', -}) => ( +const Layout = ({ children, title = 'This is the default title' }: Props) => (
{title} diff --git a/examples/with-electron-typescript/renderer/components/List.tsx b/examples/with-electron-typescript/renderer/components/List.tsx index 83183e7ba0a9..bdf2a8126344 100644 --- a/examples/with-electron-typescript/renderer/components/List.tsx +++ b/examples/with-electron-typescript/renderer/components/List.tsx @@ -1,4 +1,4 @@ -import * as React from 'react' +import React from 'react' import ListItem from './ListItem' import { User } from '../interfaces' @@ -6,7 +6,7 @@ type Props = { items: User[] } -const List: React.FunctionComponent = ({ items }) => ( +const List = ({ items }: Props) => (