Sean Proctor
02/16/2022, 8:27 PMreact.Component
with functional components? It seems like every tutorial is only using FC
's or is pretty outdated. I'm trying to create an error boundary, and I'm not that comfortable with React to begin with.turansky
02/16/2022, 11:48 PMreact.Component
- parent for class components (legacy)
react.FC
- factory for function components (modern)turansky
02/16/2022, 11:51 PMSean Proctor
02/17/2022, 8:38 AMuseErrorBoundary()
returns ErrorBoundary
component. How do I use that with functional components?turansky
02/17/2022, 3:03 PMval App = FC {
...
ErrorBoundary {
div {
ComponentWithError()
}
}
}
Sean Proctor
02/17/2022, 3:18 PMSean Proctor
02/17/2022, 3:24 PMclass ErrorBoundary(props: PropsWithChildren) : Component<PropsWithChildren, ErrorBoundaryState>(props) { ... }
and:
val App = FC<Props> {
val errorState = useErrorState(jso())
errorState.ErrorBoundary { ... }
}
Where errorState.ErrorBoundary
is a ReactElement
. Maybe that's my mistake. I couldn't get the bindings to generate for use-error-boundary, so it's possible that my translation is wrong.Sean Proctor
02/17/2022, 3:28 PMturansky
02/17/2022, 7:11 PMSean Proctor
02/17/2022, 8:05 PMval App = FC<Props> {
ErrorBoundary { ... }
}
doesn't work when error boundary is defined as a subclass of Component
.iari
03/15/2022, 9:54 AMCLOVIS
03/15/2022, 5:09 PMCLOVIS
03/15/2022, 5:11 PMSean Proctor
03/17/2022, 1:42 PM