未验证 提交 dd264f58 编写于 作者: J jmgr2996 提交者: GitHub

chore: Remove redundant imports in several examples (#13030)

上级 97a61a18
import React from 'react'
import Layout from '../components/layout' import Layout from '../components/layout'
import { useFetchUser } from '../lib/user' import { useFetchUser } from '../lib/user'
......
import React from 'react'
import Layout from '../components/layout' import Layout from '../components/layout'
import { useFetchUser } from '../lib/user' import { useFetchUser } from '../lib/user'
......
import React from 'react'
// This import is only needed when checking authentication status directly from getInitialProps // This import is only needed when checking authentication status directly from getInitialProps
// import auth0 from '../lib/auth0' // import auth0 from '../lib/auth0'
import { useFetchUser } from '../lib/user' import { useFetchUser } from '../lib/user'
......
import React from 'react'
import { useSelector, shallowEqual } from 'react-redux' import { useSelector, shallowEqual } from 'react-redux'
const useClock = () => { const useClock = () => {
......
import React from 'react'
import { useSelector, useDispatch } from 'react-redux' import { useSelector, useDispatch } from 'react-redux'
const useCounter = () => { const useCounter = () => {
......
import React from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
const ErrorMessage = ({ message }) => ( const ErrorMessage = ({ message }) => (
......
import React from 'react'
import Nav from './Nav' import Nav from './Nav'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
......
import React from 'react'
import { useMutation } from '@apollo/react-hooks' import { useMutation } from '@apollo/react-hooks'
import gql from 'graphql-tag' import gql from 'graphql-tag'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
......
import React from 'react'
import Head from 'next/head' import Head from 'next/head'
import { ApolloProvider } from '@apollo/react-hooks' import { ApolloProvider } from '@apollo/react-hooks'
import { ApolloClient } from 'apollo-client' import { ApolloClient } from 'apollo-client'
......
import React from 'react'
import { Provider } from 'react-redux' import { Provider } from 'react-redux'
import { initializeStore } from '../store' import { initializeStore } from '../store'
import App from 'next/app' import App from 'next/app'
......
import React from 'react'
import { useDispatch } from 'react-redux' import { useDispatch } from 'react-redux'
import { withRedux } from '../lib/redux' import { withRedux } from '../lib/redux'
import { compose } from 'redux' import { compose } from 'redux'
......
import React from 'react'
import { useDispatch } from 'react-redux' import { useDispatch } from 'react-redux'
import { withRedux } from '../lib/redux' import { withRedux } from '../lib/redux'
import useInterval from '../lib/useInterval' import useInterval from '../lib/useInterval'
......
import React from 'react'
import { useMutation } from '@apollo/react-hooks' import { useMutation } from '@apollo/react-hooks'
import gql from 'graphql-tag' import gql from 'graphql-tag'
......
import React from 'react'
import App from 'next/app' import App from 'next/app'
import Head from 'next/head' import Head from 'next/head'
import { ApolloProvider } from '@apollo/react-hooks' import { ApolloProvider } from '@apollo/react-hooks'
......
import React, { useReducer, useContext } from 'react' import { useReducer, useContext, createContext } from 'react'
const CounterStateContext = React.createContext() const CounterStateContext = createContext()
const CounterDispatchContext = React.createContext() const CounterDispatchContext = createContext()
const reducer = (state, action) => { const reducer = (state, action) => {
switch (action.type) { switch (action.type) {
......
import React from 'react'
import Link from 'next/link' import Link from 'next/link'
import { useCount, useDispatchCount } from '../components/Counter' import { useCount, useDispatchCount } from '../components/Counter'
......
import React from 'react'
import Link from 'next/link' import Link from 'next/link'
import { useCount, useDispatchCount } from '../components/Counter' import { useCount, useDispatchCount } from '../components/Counter'
......
import React from 'react'
export default () => { export default () => {
return <h1>Hello World!</h1> return <h1>Hello World!</h1>
} }
import * as React from 'react'
import NextApp from 'next/app' import NextApp from 'next/app'
import { CacheProvider } from '@emotion/core' import { CacheProvider } from '@emotion/core'
......
import React from 'react'
import { connect } from 'react-redux' import { connect } from 'react-redux'
const CharacterInfo = ({ const CharacterInfo = ({
......
import React from 'react'
import { Provider } from 'react-redux' import { Provider } from 'react-redux'
import App from 'next/app' import App from 'next/app'
import withRedux from 'next-redux-wrapper' import withRedux from 'next-redux-wrapper'
......
import React from 'react' import { Component } from 'react'
import Link from 'next/link' import Link from 'next/link'
import { of, Subject } from 'rxjs' import { of, Subject } from 'rxjs'
import { StateObservable } from 'redux-observable' import { StateObservable } from 'redux-observable'
...@@ -7,7 +7,7 @@ import CharacterInfo from '../components/CharacterInfo' ...@@ -7,7 +7,7 @@ import CharacterInfo from '../components/CharacterInfo'
import { rootEpic } from '../redux/epics' import { rootEpic } from '../redux/epics'
import * as actions from '../redux/actions' import * as actions from '../redux/actions'
class Counter extends React.Component { class Counter extends Component {
static async getInitialProps({ store, isServer }) { static async getInitialProps({ store, isServer }) {
const state$ = new StateObservable(new Subject(), store.getState()) const state$ = new StateObservable(new Subject(), store.getState())
const resultAction = await rootEpic( const resultAction = await rootEpic(
......
import React from 'react'
import Link from 'next/link' import Link from 'next/link'
const OtherPage = () => ( const OtherPage = () => (
......
import React, { Component } from 'react' import { Component } from 'react'
import { connect } from 'react-redux' import { connect } from 'react-redux'
import { bindActionCreators } from 'redux' import { bindActionCreators } from 'redux'
import { incrementCount, decrementCount, resetCount } from '../store' import { incrementCount, decrementCount, resetCount } from '../store'
......
import React, { Component } from 'react' import { Component } from 'react'
import { connect } from 'react-redux' import { connect } from 'react-redux'
import { bindActionCreators } from 'redux' import { bindActionCreators } from 'redux'
import { loadExampleData, loadingExampleDataFailure } from '../store' import { loadExampleData, loadingExampleDataFailure } from '../store'
......
import React from 'react' import { Component } from 'react'
import { initializeStore } from '../store' import { initializeStore } from '../store'
const isServer = typeof window === 'undefined' const isServer = typeof window === 'undefined'
...@@ -18,7 +18,7 @@ function getOrCreateStore(initialState) { ...@@ -18,7 +18,7 @@ function getOrCreateStore(initialState) {
} }
export default App => { export default App => {
return class AppWithRedux extends React.Component { return class AppWithRedux extends Component {
static async getInitialProps(appContext) { static async getInitialProps(appContext) {
// Get or Create the store with `undefined` as initialState // Get or Create the store with `undefined` as initialState
// This allows you to set a custom default initialState // This allows you to set a custom default initialState
......
import App from 'next/app' import App from 'next/app'
import React from 'react'
import withReduxStore from '../lib/with-redux-store' import withReduxStore from '../lib/with-redux-store'
import { Provider } from 'react-redux' import { Provider } from 'react-redux'
import { persistStore } from 'redux-persist' import { persistStore } from 'redux-persist'
......
import React from 'react' import { Component } from 'react'
import { connect } from 'react-redux' import { connect } from 'react-redux'
import { startClock, serverRenderClock } from '../store' import { startClock, serverRenderClock } from '../store'
import Examples from '../components/examples' import Examples from '../components/examples'
class Index extends React.Component { class Index extends Component {
static getInitialProps({ reduxStore, req }) { static getInitialProps({ reduxStore, req }) {
const isServer = !!req const isServer = !!req
// DISPATCH ACTIONS HERE ONLY WITH `reduxStore.dispatch` // DISPATCH ACTIONS HERE ONLY WITH `reduxStore.dispatch`
......
import React from 'react'
const pad = n => (n < 10 ? `0${n}` : n) const pad = n => (n < 10 ? `0${n}` : n)
const format = t => { const format = t => {
......
import React, { Component } from 'react' import { Component } from 'react'
import { connect } from 'react-redux' import { connect } from 'react-redux'
import { increment, decrement, reset } from '../actions' import { increment, decrement, reset } from '../actions'
......
import App from 'next/app' import App from 'next/app'
import React from 'react'
import { Provider } from 'react-redux' import { Provider } from 'react-redux'
import withRedux from 'next-redux-wrapper' import withRedux from 'next-redux-wrapper'
import withReduxSaga from 'next-redux-saga' import withReduxSaga from 'next-redux-saga'
......
import React from 'react' import { Component } from 'react'
import { connect } from 'react-redux' import { connect } from 'react-redux'
import { loadData, startClock, tickClock } from '../actions' import { loadData, startClock, tickClock } from '../actions'
import Page from '../components/page' import Page from '../components/page'
class Index extends React.Component { class Index extends Component {
static async getInitialProps(props) { static async getInitialProps(props) {
const { store, isServer } = props.ctx const { store, isServer } = props.ctx
store.dispatch(tickClock(isServer)) store.dispatch(tickClock(isServer))
......
import React from 'react' import { Component } from 'react'
import { connect } from 'react-redux' import { connect } from 'react-redux'
import { startClock, tickClock } from '../actions' import { startClock, tickClock } from '../actions'
import Page from '../components/page' import Page from '../components/page'
class Other extends React.Component { class Other extends Component {
static async getInitialProps(props) { static async getInitialProps(props) {
const { store, isServer } = props.ctx const { store, isServer } = props.ctx
store.dispatch(tickClock(isServer)) store.dispatch(tickClock(isServer))
......
import React from 'react'
const pad = n => (n < 10 ? `0${n}` : n) const pad = n => (n < 10 ? `0${n}` : n)
const format = t => const format = t =>
......
import React from 'react'
import { useSelector, useDispatch } from 'react-redux' import { useSelector, useDispatch } from 'react-redux'
import { incrementCount, decrementCount, resetCount } from '../actions' import { incrementCount, decrementCount, resetCount } from '../actions'
......
import React from 'react'
import { useSelector } from 'react-redux' import { useSelector } from 'react-redux'
import Clock from './clock' import Clock from './clock'
import Counter from './counter' import Counter from './counter'
......
import React from 'react' import { Component } from 'react'
import initializeStore from '../store' import initializeStore from '../store'
const __NEXT_REDUX_STORE__ = '__NEXT_REDUX_STORE__' const __NEXT_REDUX_STORE__ = '__NEXT_REDUX_STORE__'
...@@ -17,7 +17,7 @@ function getOrCreateStore(initialState) { ...@@ -17,7 +17,7 @@ function getOrCreateStore(initialState) {
} }
export default App => { export default App => {
return class AppWithRedux extends React.Component { return class AppWithRedux extends Component {
static async getInitialProps(appContext) { static async getInitialProps(appContext) {
// Get or Create the store with `undefined` as initialState // Get or Create the store with `undefined` as initialState
// This allows you to set a custom default initialState // This allows you to set a custom default initialState
......
import React from 'react'
import { Provider } from 'react-redux' import { Provider } from 'react-redux'
import App from 'next/app' import App from 'next/app'
import withReduxStore from '../lib/with-redux-store' import withReduxStore from '../lib/with-redux-store'
......
import React, { PureComponent } from 'react' import { PureComponent } from 'react'
import { connect } from 'react-redux' import { connect } from 'react-redux'
import Link from 'next/link' import Link from 'next/link'
import { startClock, serverRenderClock } from '../actions' import { startClock, serverRenderClock } from '../actions'
......
import React from 'react'
import { connect } from 'react-redux' import { connect } from 'react-redux'
import Link from 'next/link' import Link from 'next/link'
......
import React from 'react'
import { useSelector, shallowEqual } from 'react-redux' import { useSelector, shallowEqual } from 'react-redux'
const useClock = () => { const useClock = () => {
......
import React from 'react'
import { createAction } from '@reduxjs/toolkit' import { createAction } from '@reduxjs/toolkit'
import { useSelector, useDispatch } from 'react-redux' import { useSelector, useDispatch } from 'react-redux'
......
import React from 'react'
import { Provider } from 'react-redux' import { Provider } from 'react-redux'
import { store } from '../store' import { store } from '../store'
......
import React from 'react'
import { createAction } from '@reduxjs/toolkit' import { createAction } from '@reduxjs/toolkit'
import { connect } from 'react-redux' import { connect } from 'react-redux'
import useInterval from '../lib/useInterval' import useInterval from '../lib/useInterval'
......
...@@ -58,7 +58,6 @@ When wrapping a [Link](https://nextjs.org/docs/api-reference/next/link) from `ne ...@@ -58,7 +58,6 @@ When wrapping a [Link](https://nextjs.org/docs/api-reference/next/link) from `ne
**components/StyledLink.js** **components/StyledLink.js**
```javascript ```javascript
import React from 'react'
import Link from 'next/link' import Link from 'next/link'
import styled from 'styled-components' import styled from 'styled-components'
...@@ -88,7 +87,6 @@ export default styled(StyledLink)` ...@@ -88,7 +87,6 @@ export default styled(StyledLink)`
**pages/index.js** **pages/index.js**
```javascript ```javascript
import React from 'react'
import StyledLink from '../components/StyledLink' import StyledLink from '../components/StyledLink'
export default () => ( export default () => (
......
import App from 'next/app' import App from 'next/app'
import React from 'react'
import { ThemeProvider } from 'styled-components' import { ThemeProvider } from 'styled-components'
const theme = { const theme = {
......
import React from 'react'
import styled from 'styled-components' import styled from 'styled-components'
const Title = styled.h1` const Title = styled.h1`
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册