-
-
Notifications
You must be signed in to change notification settings - Fork 27k
Updated react-error-overlay to latest Flow (0.54.0) #3065
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
Changes from 4 commits
6deaffb
ef9e90f
15129c9
a784af7
a910670
fc7c742
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,8 @@ import CodeBlock from './StackFrameCodeBlock'; | |
import { getPrettyURL } from '../utils/getPrettyURL'; | ||
import { darkGray } from '../styles'; | ||
|
||
import type { StackFrame as StackFrameType } from '../utils/stack-frame'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here (and below). |
||
|
||
const linkStyle = { | ||
fontSize: '0.9em', | ||
marginBottom: '0.9em', | ||
|
@@ -43,7 +45,19 @@ const toggleStyle = { | |
lineHeight: '1.5', | ||
}; | ||
|
||
class StackFrame extends Component { | ||
type Props = {| | ||
frame: StackFrameType, | ||
launchEditorEndpoint: ?string, | ||
contextSize: number, | ||
critical: boolean, | ||
showCode: boolean, | ||
|}; | ||
|
||
type State = {| | ||
compiled: boolean, | ||
|}; | ||
|
||
class StackFrame extends Component<Props, State> { | ||
state = { | ||
compiled: false, | ||
}; | ||
|
@@ -74,7 +88,7 @@ class StackFrame extends Component { | |
} | ||
|
||
openInEditor = () => { | ||
if (!this.canOpenInEditor()) { | ||
if (!this.props.launchEditorEndpoint) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did this change? Seems like it's more permissive than it used to be. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry I have no idea how to fix this other than adding the same condition twice.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can replace There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not working because you're not using the return value and instead read the same thing again from props. Flow doesn't know the props are immutable so it's bailing out thinking they might have changed. I am suggesting to use the return value of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are calling the function twice. Flow can’t know that the value hasn’t changed since last call. You need to do this: const endpointUrl = this.getEndpointUrl();
if (endpointUrl === null) {
return;
}
// ...
// By now Flow knows endpointUrl can't possibly be null
fetch(
`${endpointUrl}/...`
) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you, now I understand. |
||
return; | ||
} | ||
const { | ||
|
@@ -90,7 +104,7 @@ class StackFrame extends Component { | |
).then(() => {}, () => {}); | ||
}; | ||
|
||
onKeyDown = (e: SyntheticKeyboardEvent) => { | ||
onKeyDown = (e: SyntheticKeyboardEvent<>) => { | ||
if (e.key === 'Enter') { | ||
this.openInEditor(); | ||
} | ||
|
@@ -155,9 +169,7 @@ class StackFrame extends Component { | |
const canOpenInEditor = this.canOpenInEditor(); | ||
return ( | ||
<div> | ||
<div> | ||
{functionName} | ||
</div> | ||
<div>{functionName}</div> | ||
<div style={linkStyle}> | ||
<a | ||
style={canOpenInEditor ? anchorStyle : null} | ||
|
@@ -168,7 +180,7 @@ class StackFrame extends Component { | |
{url} | ||
</a> | ||
</div> | ||
{codeBlockProps && | ||
{codeBlockProps && ( | ||
<span> | ||
<a | ||
onClick={canOpenInEditor ? this.openInEditor : null} | ||
|
@@ -179,7 +191,8 @@ class StackFrame extends Component { | |
<button style={toggleStyle} onClick={this.toggleCompiled}> | ||
{'View ' + (compiled ? 'source' : 'compiled')} | ||
</button> | ||
</span>} | ||
</span> | ||
)} | ||
</div> | ||
); | ||
} | ||
|
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.
Could you please always add newline before
import type
s?