New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove react-hot-loader #4500
Merged
timneutkens
merged 12 commits into
vercel:canary
from
timneutkens:fix/remove-react-hot-loader
May 31, 2018
Merged
Remove react-hot-loader #4500
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
83809d1
Remove react-hot-loader
timneutkens 6a117fe
Make _app.js compatible with hot-self-accept-loader
timneutkens 190a5d5
Pass app to renderError
timneutkens 06b0bae
Add error boundary component and move overlay into client folder
timneutkens bc7d7c8
Module is optional
timneutkens 4ec01fa
Make types consistent
timneutkens 0f7d470
Run flow on pretest
timneutkens e6a30c9
Run node.js on x64 for flow-type support
timneutkens 7aff251
Use exact object
timneutkens 2170024
Use intersection types
timneutkens 6952197
Check for development instead of production
timneutkens 5dbe264
Add note about componentDidCatch
timneutkens File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
[ignore] | ||
<PROJECT_ROOT>/examples/.* | ||
<PROJECT_ROOT>/examples/.* | ||
<PROJECT_ROOT>/.*.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// @flow | ||
import React from 'react' | ||
import {applySourcemaps} from './source-map-support' | ||
import ErrorDebug, {styles} from '../lib/error-debug' | ||
import type {RuntimeError, ErrorReporterProps} from './error-boundary' | ||
|
||
type State = {| | ||
mappedError: null | RuntimeError | ||
|} | ||
|
||
// This component is only used in development, sourcemaps are applied on the fly because componentDidCatch is not async | ||
class DevErrorOverlay extends React.Component<ErrorReporterProps, State> { | ||
state = { | ||
mappedError: null | ||
} | ||
|
||
componentDidMount () { | ||
const {error} = this.props | ||
|
||
// Since componentDidMount doesn't handle errors we use then/catch here | ||
applySourcemaps(error).then(() => { | ||
this.setState({mappedError: error}) | ||
}).catch((caughtError) => { | ||
this.setState({mappedError: caughtError}) | ||
}) | ||
} | ||
|
||
render () { | ||
const {mappedError} = this.state | ||
const {info} = this.props | ||
if (mappedError === null) { | ||
return <div style={styles.errorDebug}> | ||
<h1 style={styles.heading}>Loading stacktrace...</h1> | ||
</div> | ||
} | ||
|
||
return <ErrorDebug error={mappedError} info={info} /> | ||
} | ||
} | ||
|
||
export default DevErrorOverlay |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// @flow | ||
import * as React from 'react' | ||
import {polyfill} from 'react-lifecycles-compat' | ||
|
||
type ComponentDidCatchInfo = { | ||
componentStack: string | ||
} | ||
|
||
export type Info = null | ComponentDidCatchInfo | ||
|
||
export type RuntimeError = Error & {| | ||
module: ?{| | ||
rawRequest: string | ||
|} | ||
|} | ||
|
||
export type ErrorReporterProps = {|error: RuntimeError, info: Info|} | ||
type ErrorReporterComponent = React.ComponentType<ErrorReporterProps> | ||
|
||
type Props = {| | ||
ErrorReporter: null | ErrorReporterComponent, | ||
onError: (error: RuntimeError, info: ComponentDidCatchInfo) => void, | ||
children: React.ComponentType<*> | ||
|} | ||
|
||
type State = {| | ||
error: null | RuntimeError, | ||
info: Info | ||
|} | ||
|
||
class ErrorBoundary extends React.Component<Props, State> { | ||
state = { | ||
error: null, | ||
info: null | ||
} | ||
static getDerivedStateFromProps () { | ||
return { | ||
error: null, | ||
info: null | ||
} | ||
} | ||
componentDidCatch (error: RuntimeError, info: ComponentDidCatchInfo) { | ||
const {onError} = this.props | ||
|
||
// onError is provided in production | ||
if (onError) { | ||
onError(error, info) | ||
} else { | ||
this.setState({ error, info }) | ||
} | ||
} | ||
render () { | ||
const {ErrorReporter, children} = this.props | ||
const {error, info} = this.state | ||
if (ErrorReporter && error) { | ||
return <ErrorReporter error={error} info={info} /> | ||
} | ||
|
||
return React.Children.only(children) | ||
} | ||
} | ||
|
||
// Makes sure we can use React 16.3 lifecycles and still support older versions of React. | ||
polyfill(ErrorBoundary) | ||
|
||
export default ErrorBoundary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// flow-typed signature: 729d832efcac0a21ab881042caf78e1e | ||
// flow-typed version: <<STUB>>/react-lifecycles-compat_v3.0.4/flow_v0.73.0 | ||
|
||
/** | ||
* This is an autogenerated libdef stub for: | ||
* | ||
* 'react-lifecycles-compat' | ||
* | ||
* Fill this stub out by replacing all the `any` types. | ||
* | ||
* Once filled out, we encourage you to share your work with the | ||
* community by sending a pull request to: | ||
* https://github.com/flowtype/flow-typed | ||
*/ | ||
|
||
declare module 'react-lifecycles-compat' { | ||
declare module.exports: any; | ||
} | ||
|
||
/** | ||
* We include stubs for each file inside this npm package in case you need to | ||
* require those files directly. Feel free to delete any files that aren't | ||
* needed. | ||
*/ | ||
declare module 'react-lifecycles-compat/react-lifecycles-compat.cjs' { | ||
declare module.exports: any; | ||
} | ||
|
||
declare module 'react-lifecycles-compat/react-lifecycles-compat.es' { | ||
declare module.exports: any; | ||
} | ||
|
||
declare module 'react-lifecycles-compat/react-lifecycles-compat' { | ||
declare module.exports: any; | ||
} | ||
|
||
declare module 'react-lifecycles-compat/react-lifecycles-compat.min' { | ||
declare module.exports: any; | ||
} | ||
|
||
// Filename aliases | ||
declare module 'react-lifecycles-compat/react-lifecycles-compat.cjs.js' { | ||
declare module.exports: $Exports<'react-lifecycles-compat/react-lifecycles-compat.cjs'>; | ||
} | ||
declare module 'react-lifecycles-compat/react-lifecycles-compat.es.js' { | ||
declare module.exports: $Exports<'react-lifecycles-compat/react-lifecycles-compat.es'>; | ||
} | ||
declare module 'react-lifecycles-compat/react-lifecycles-compat.js' { | ||
declare module.exports: $Exports<'react-lifecycles-compat/react-lifecycles-compat'>; | ||
} | ||
declare module 'react-lifecycles-compat/react-lifecycles-compat.min.js' { | ||
declare module.exports: $Exports<'react-lifecycles-compat/react-lifecycles-compat.min'>; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
possible to
// @flow
this or should we do that in a later PR (i.e. PR just to flowtype more things)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I didn't on purpose, carefully chose which files to start with 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍