Conversation
1875480 to
71c4447
Compare
There was a problem hiding this comment.
https://fireflydev.ipac.caltech.edu/firefly-1127-react-18/firefly/test/tests-main.html
- image viewer in test 4 and 5 is no longer working as expected
Same goes for slate.html
https://fireflydev.ipac.caltech.edu/firefly-1127-react-18/firefly/test/tests-chart.html
- test 1 and 5 is no longer working
https://fireflydev.ipac.caltech.edu/firefly/test/test-hips-mocs.html
- similar to main tests, none of the image viewers work.
https://fireflydev.ipac.caltech.edu/firefly-1127-react-18/firefly/test/test-coverage.html
https://fireflydev.ipac.caltech.edu/firefly/test/test-image.html
- same problem with coverage and image tests
| const rootToUse = root ?? createRoot(e); | ||
| const webApi= isUsingWebApi(webApiCommands); | ||
| const doAppRender= () => ReactDOM.render(React.createElement(viewer, {...props, normalInit: !webApi }), e); | ||
| const doAppRender= () => rootToUse.render( React.createElement(viewer, {...props, normalInit: !webApi }) ); |
There was a problem hiding this comment.
Have you tried adding an ErrorBoundary around the 'viewer' to see if it'll catch all uncaught errors?
It may not work as expected, but it's worth a try. There's very little code needed to make this happen.
const app = React.createElement(viewer, ...
rootToUse.render(
<ErrorBoundary>
{app}
</ErrorBoundary>,
... There was a problem hiding this comment.
I was looking for ErrorBoundary but could not find it in the docs.
There was a problem hiding this comment.
I still can't fine it. Can you point me to the docs?
There was a problem hiding this comment.
As far as I can tell this is only documented in the legacy API my creating such a component using componentDidCatch() and getDerivedStateFromError(), but this is in what they now call their Legacy React API.
There was a problem hiding this comment.
I have no idea whether or not an uncaught exception would propagate to the root rendering. I was only curious to see if you've tried. Below is a 'class' based implementation. There's a functional version as well. If it does, then we can at least intercept it and provide messages with some sort of reset link.
https://legacy.reactjs.org/docs/error-boundaries.html
class ErrorBoundary extends React.Component {
constructor(props) {
super(props);
this.state = { hasError: false };
}
static getDerivedStateFromError(error) {
// Update state so the next render will show the fallback UI.
return { hasError: true };
}
componentDidCatch(error, errorInfo) {
// You can also log the error to an error reporting service
logErrorToMyService(error, errorInfo);
}
render() {
if (this.state.hasError) {
// You can render any custom fallback UI
return <h1>Something went wrong.</h1>;
}
return this.props.children;
}
}There was a problem hiding this comment.
yes, this is what I have found as well. This was added in react 16. They are now acting like it is 'legacy'. Either way it is out of scope for this PR. We could have put this in for the last 2 years. I think it is a different task from the upgrade.
|
I think there is a problem with loading react in the API. I will look into it |
71c4447 to
d1bca1a
Compare
- upgrading some other packages as well - Trying out useTransition() hook in useStoreConnector - Trying useDeferredValue in ImageViewer
d1bca1a to
2d725fe
Compare
Firefly-1127: upgrade react to 18
building.
cd <path-to-firefly>/fireflyrm -rf node_modulesyarn --frozen-lockfileTest:
Important notes about React 18:
undefineduseTransition/startTransition(bad naming, I think) are ways to make a component render run at a lower priority, It will not block normal rendersuseDeferredValueis another ways to make component run at a lesser priority. I am not sure I quite understand it yet but I put I am trying it in one compoenent