Skip to content

Commit 2828b01

Browse files
authored
Fixing Redundant React imports on next.js/examples (vercel#13384)
Per vercel#12964 * with-ant-design * with-dynamic-import * with-iron-session * with-monaco-editor * with-next-page-transitions * with-react-with-styles * with-style-sheet * with-why-did-you-render Tested each example, working as intended, no additional issues presented
1 parent d56d5e6 commit 2828b01

File tree

13 files changed

+8
-24
lines changed

13 files changed

+8
-24
lines changed

examples/with-ant-design/pages/_app.js

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import React from 'react'
2-
31
import 'antd/dist/antd.css'
42
import '../styles/vars.css'
53
import '../styles/global.css'

examples/with-dynamic-import/pages/index.js

+5-9
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
1-
import React, { useState } from 'react'
1+
import { useState } from 'react'
22
import Header from '../components/Header'
33
import dynamic from 'next/dynamic'
44

55
const DynamicComponent1 = dynamic(() => import('../components/hello1'))
66

77
const DynamicComponent2WithCustomLoading = dynamic(
88
() => import('../components/hello2'),
9-
{
10-
loading: () => <p>Loading caused by client page transition ...</p>,
11-
}
9+
{ loading: () => <p>Loading caused by client page transition ...</p> }
1210
)
1311

1412
const DynamicComponent3WithNoSSR = dynamic(
1513
() => import('../components/hello3'),
16-
{
17-
loading: () => <p>Loading ...</p>,
18-
ssr: false,
19-
}
14+
{ loading: () => <p>Loading ...</p>, ssr: false }
2015
)
2116

2217
const DynamicComponent4 = dynamic(() => import('../components/hello4'))
@@ -25,6 +20,7 @@ const DynamicComponent5 = dynamic(() => import('../components/hello5'))
2520

2621
const IndexPage = () => {
2722
const [showMore, setShowMore] = useState(false)
23+
const [falsyField] = useState(false)
2824

2925
return (
3026
<div>
@@ -40,7 +36,7 @@ const IndexPage = () => {
4036
<DynamicComponent3WithNoSSR />
4137

4238
{/* This component will never be loaded */}
43-
{React.noSuchField && <DynamicComponent4 />}
39+
{falsyField && <DynamicComponent4 />}
4440

4541
{/* Load on demand */}
4642
{showMore && <DynamicComponent5 />}

examples/with-iron-session/pages/index.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react'
21
import Layout from '../components/Layout'
32

43
const Home = () => (

examples/with-iron-session/pages/login.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react'
21
import { useState } from 'react'
32
import useUser from '../lib/useUser'
43
import Layout from '../components/Layout'

examples/with-iron-session/pages/profile-sg.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react'
21
import useUser from '../lib/useUser'
32
import Layout from '../components/Layout'
43

examples/with-iron-session/pages/profile-ssr.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react'
21
import Layout from '../components/Layout'
32
import withSession from '../lib/session'
43
import PropTypes from 'prop-types'

examples/with-monaco-editor/pages/index.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react'
21
import dynamic from 'next/dynamic'
32

43
import sample from '../code-sample'

examples/with-next-page-transitions/pages/_app.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react'
21
import { PageTransition } from 'next-page-transitions'
32

43
import Loader from '../components/Loader'

examples/with-next-page-transitions/pages/_document.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react'
21
import Document, { Head, Main, NextScript } from 'next/document'
32

43
export default class MyDocument extends Document {

examples/with-next-page-transitions/pages/index.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react'
21
import Link from 'next/link'
32

43
const Index = () => (

examples/with-react-with-styles/pages/_app.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react'
21
import { DIRECTIONS } from 'react-with-direction'
32
import AphroditeInterface from 'react-with-styles-interface-aphrodite'
43
import WithStylesContext from 'react-with-styles/lib/WithStylesContext'

examples/with-react-with-styles/pages/index.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react'
21
import { css, withStyles } from 'react-with-styles'
32

43
function Home({ styles }) {

examples/with-style-sheet/pages/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import React from 'react'
1+
import { useState, useEffect } from 'react'
22
import { StyleSheet, StyleResolver } from 'style-sheet'
33
const cls = StyleResolver.resolve
44

55
export default function Home() {
6-
const [color, setColor] = React.useState('#111')
7-
React.useEffect(() => {
6+
const [color, setColor] = useState('#111')
7+
useEffect(() => {
88
setTimeout(() => {
99
setColor('#00f')
1010
}, 2000)

0 commit comments

Comments
 (0)