Open angrave opened 9 months ago
A quick test of changing a component (not a screeen) from dva to react-redux leads to runtime error when the component is displayed. e.g. CTPopup.jsx
import { connect } from 'react-redux'; // 'dva'
In the console-
Uncaught Error: Could not find "store" in the context of "Connect(CTPopup)". Either wrap the root component in a <Provider>, or pass a custom React context provider to <Provider> and the corresponding React context consumer to Connect(CTPopup) in connect options.
This is surprising because (based on some quick searches) dvajs appears to just export redux's connect. Perhaps we're skipped to a newer version of redux (or react-redux) than what dvajs specifies internally (7.1.5)? Or some automatic glue that occurs when js imports dva??
Looks like dvaJS just added support for React 18 and I don't think it's blocking a node upgrade either, so we can actually hit those first, upgrade our other dependencies and then tackle dvaJS.
I do think it's still worth removing since the React world has largely moved on from the conventions of then, and newer libraries have solved the issues dva solved. A lot of the documentation isn't in English and all the other reasons of removing it still hold. Removing dvaJS has a few different parts. Their official documentation says:
redux, redux-saga and react-router
Removing DvaJS will be in a few parts of just using the underlying libraries by themselves instead of dva itself.
dva/saga
(about 11 files)
effect:
blocks with *functions
as well as delay
used onceconnect
: 52 files
For each pattern we can maybe write tests for 2-3 files for existing behavior, then replace the dvajs
calls with the underlying library calls to make sure it still works.
More motivation to remove dva: https://github.com/classtranscribe/FrontEnd/pull/648 😩
Tracking react upgrade here: https://github.com/classtranscribe/FrontEnd/issues/818, maybe after this, we can tackle removing dvajs
https://umijs.org/ - looks like the Chinese big tech community has largely moved onto umi which takes the dva react concepts further and creates a tighter integration with fewer APIs required. So looks DVA is largely a thing of the past now from what I can tell
dvajs is legacy, unmaintained, poorly documented and preventing us from moving to a more recent react version. It is likely that modern react components mean we don't need it.
We are using it for routing, history, and redux connect. However there are warnings in the browser console that are likely from dva -