-
-
Notifications
You must be signed in to change notification settings - Fork 198
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
Unnecessary dependencies on package.json when installing #5
Comments
But I just realized that to remove these as a dependency, than you should generate a compiled version (without Flow), right? |
Whoops! I probably just forked another OSS project I had to create this one and wasn't careful about cleaning up dependencies. That or I forgot the Either way, sorry. I'll tidy up before the next release. |
Should be fixed in 1.1.0! |
@bvaughn Nice! :D I've copied the component code without Flow (using prop-types instead) to my project, so no extra dependencies were needed, the main part is small actually: import React, { Component } from 'react'
import PropTypes from 'prop-types'
class ErrorBoundary extends Component {
constructor(props, context) {
super(props, context)
this.state = {
error: null,
info: null,
}
}
componentDidCatch(error, info) {
const { onError } = this.props
if (typeof onError === 'function') {
try {
onError(error, info ? info.componentStack : '')
} catch (error) {}
}
this.setState({ error, info })
}
render() {
const { children, FallbackComponent } = this.props
const { error, info } = this.state
if (error !== null) {
return (
<FallbackComponent
componentStack={info ? info.componentStack : ''}
error={error}
/>
)
}
return children
}
}
ErrorBoundary.propTypes = {
children: PropTypes.any,
FallbackComponent: PropTypes.any.isRequired,
onError: PropTypes.func,
}
export default ErrorBoundary |
Will prob do a follow-up release to generate prop-types from the Flow types for people who prefer to use them. Although I guess there's not much motivation if you just embed the tiny component 😄 |
@bvaughn oh but you should definitely do it anyway, not all people use Flow. Thanks for the great work, this React 16 componentDidCatch feature that this component helps to use is very Nice! :D |
Even thought most of these dependencies were on my devDependencies, yarn add it to yarn.lock and node_modules:
I believe most of those dependencies should be a devDependency and prop-types is not a dependency, since you use flow
The text was updated successfully, but these errors were encountered: