Skip to content

Commit

Permalink
Fixing Redundant React imports on next.js/examples (#13384)
Browse files Browse the repository at this point in the history
Per #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
  • Loading branch information
awareness481 authored May 26, 2020
1 parent d56d5e6 commit 2828b01
Show file tree
Hide file tree
Showing 13 changed files with 8 additions and 24 deletions.
2 changes: 0 additions & 2 deletions examples/with-ant-design/pages/_app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react'

import 'antd/dist/antd.css'
import '../styles/vars.css'
import '../styles/global.css'
Expand Down
14 changes: 5 additions & 9 deletions examples/with-dynamic-import/pages/index.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
import React, { useState } from 'react'
import { useState } from 'react'
import Header from '../components/Header'
import dynamic from 'next/dynamic'

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

const DynamicComponent2WithCustomLoading = dynamic(
() => import('../components/hello2'),
{
loading: () => <p>Loading caused by client page transition ...</p>,
}
{ loading: () => <p>Loading caused by client page transition ...</p> }
)

const DynamicComponent3WithNoSSR = dynamic(
() => import('../components/hello3'),
{
loading: () => <p>Loading ...</p>,
ssr: false,
}
{ loading: () => <p>Loading ...</p>, ssr: false }
)

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

const IndexPage = () => {
const [showMore, setShowMore] = useState(false)
const [falsyField] = useState(false)

return (
<div>
Expand All @@ -40,7 +36,7 @@ const IndexPage = () => {
<DynamicComponent3WithNoSSR />

{/* This component will never be loaded */}
{React.noSuchField && <DynamicComponent4 />}
{falsyField && <DynamicComponent4 />}

{/* Load on demand */}
{showMore && <DynamicComponent5 />}
Expand Down
1 change: 0 additions & 1 deletion examples/with-iron-session/pages/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react'
import Layout from '../components/Layout'

const Home = () => (
Expand Down
1 change: 0 additions & 1 deletion examples/with-iron-session/pages/login.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react'
import { useState } from 'react'
import useUser from '../lib/useUser'
import Layout from '../components/Layout'
Expand Down
1 change: 0 additions & 1 deletion examples/with-iron-session/pages/profile-sg.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react'
import useUser from '../lib/useUser'
import Layout from '../components/Layout'

Expand Down
1 change: 0 additions & 1 deletion examples/with-iron-session/pages/profile-ssr.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react'
import Layout from '../components/Layout'
import withSession from '../lib/session'
import PropTypes from 'prop-types'
Expand Down
1 change: 0 additions & 1 deletion examples/with-monaco-editor/pages/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react'
import dynamic from 'next/dynamic'

import sample from '../code-sample'
Expand Down
1 change: 0 additions & 1 deletion examples/with-next-page-transitions/pages/_app.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react'
import { PageTransition } from 'next-page-transitions'

import Loader from '../components/Loader'
Expand Down
1 change: 0 additions & 1 deletion examples/with-next-page-transitions/pages/_document.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react'
import Document, { Head, Main, NextScript } from 'next/document'

export default class MyDocument extends Document {
Expand Down
1 change: 0 additions & 1 deletion examples/with-next-page-transitions/pages/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react'
import Link from 'next/link'

const Index = () => (
Expand Down
1 change: 0 additions & 1 deletion examples/with-react-with-styles/pages/_app.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react'
import { DIRECTIONS } from 'react-with-direction'
import AphroditeInterface from 'react-with-styles-interface-aphrodite'
import WithStylesContext from 'react-with-styles/lib/WithStylesContext'
Expand Down
1 change: 0 additions & 1 deletion examples/with-react-with-styles/pages/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react'
import { css, withStyles } from 'react-with-styles'

function Home({ styles }) {
Expand Down
6 changes: 3 additions & 3 deletions examples/with-style-sheet/pages/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from 'react'
import { useState, useEffect } from 'react'
import { StyleSheet, StyleResolver } from 'style-sheet'
const cls = StyleResolver.resolve

export default function Home() {
const [color, setColor] = React.useState('#111')
React.useEffect(() => {
const [color, setColor] = useState('#111')
useEffect(() => {
setTimeout(() => {
setColor('#00f')
}, 2000)
Expand Down

0 comments on commit 2828b01

Please sign in to comment.