Dva is a lightweight, Elm-style front-end framework designed for building single-page applications by integrating React, Redux, React Router, and Redux Saga into a cohesive development experience. It simplifies state management and side effects through a declarative model system and streamlined data flow, aiming to reduce boilerplate typically associated with Redux setups. The package's last stable release, version 2.4.1, dates back to 2018, with subsequent beta versions for 2.6.0 released in late 2019. The project currently exhibits an abandoned release cadence, with no further stable releases or active development beyond 2019. Its key differentiators include an opinionated, "batteries-included" approach that pre-configures major React ecosystem libraries and its model-centric architecture for managing application state and logic.
npm install dvaVerified import paths — ran on the pinned version, not inferred.
Demonstrates a basic Dva application setup with a model (state, reducers, effects, subscriptions) and routing using `dva/router`, showing how to connect a component to the Redux store.
For new projects, consider modern alternatives like UmiJS, Rematch, or Redux Toolkit. For existing projects, plan for migration to a maintained framework.
Ensure your project's `react` and `react-dom` versions are within the specified range (15.x or 16.x). If upgrading React is necessary, a migration away from Dva might be required.
Stick to `react-router-dom` v5.x or earlier if using Dva's integrated router. If migrating to `react-router-dom` v6, you will likely need to rewrite Dva's router setup and potentially model subscriptions that rely on router events.
Install compatible versions of React and ReactDOM: `npm install react@^16.0.0 react-dom@^16.0.0` or `yarn add react@^16.0.0 react-dom@^16.0.0`.
Add a unique `namespace` string property to your Dva model definition, e.g., `app.model({ namespace: 'myModel', ... });`.Ensure your component is wrapped with Dva's `connect` higher-order component, which injects `dispatch` as a prop: `export default connect((state) => ({ ...state }))(MyComponent);`.