Releases: vivekmunde/duxact
Releases · vivekmunde/duxact
2.4.2
1.4.1
Release notes
- Source map for Development mode
Breaking changes:
- None
2.4.1
Release notes
- Bug fixes
useSelector
: TheuseSelector
hook was triggering unnecessary re-renders. This was because the equality function was not receiving the last updated state. It has been fixed now.
Breaking changes:
- None
2.4.0
Release notes
connect
,connectState
,useSelector
: Facility to passequality
function for state comparison (old vs new state)- Documentation update
Breaking changes:
- None
1.4.0
Release notes
connect
&connectState
: Facility to passequality
function for state comparison (old vs new state)- Documentation update
Breaking changes:
- None
2.3.0
Release notes
- Hooks
useSelector
: Hook for consuming stateuseDispatch
: Hook for dispatching actions
- Test coverage for Deep Comparison for
connect
,connectState
&useSelector
- Documentation update
Breaking changes:
- None
1.3.2
Release notes
- Documentation update
- Test coverage for Deep Comparison for
connect
&connectState
Breaking changes:
- None
1.3.1
Release notes
- Bundle size reduction
- Documentation update
Breaking changes:
- None
2.2.1
Release notes
- Bundle size reduction
- Documentation update
Breaking changes:
- None
2.2.0
Release notes
- Deep comparison: Deep compare the changed state and old state, state derived from the
mapStateToProps
selector. It updates the consumer component only if new state (derived from the mapStateToProps) has changed with respect to the old state. This avoids unnecessary re-renders of the consumer components.
In below example, componentUserDetails
will receive fresh props,name
&address
, only ifname
and/oraddress
of theloggedInUser
object gets updated in store. Because the mapStateToProps (selector) returns only thename
&address
fields ofloggedInUser
. So even if other data likedateOfBirth
,age
etc of theloggedInUser
are changed, the consumer componentUserDetails
do not receive freshly mappedname
&address
, to avoid re-rendering ofUserDetails
.
Please note, if any parent component in the hierarchy of the
UserDetails
has re-rendered thenUserDetails
will also re-render. Its a default behavior of react components. To avoid this use React.PureComponent or React.memo or shouldComponentUpdate.
import { connect } from 'duxact';
const mapStateToProps = (currentState) => ({
name: currentState.loggedInUser.name,
address: currentState.loggedInUser.address
});
const UserDetails = ({ name, address }) => (
<div>
<label>{name}</label>
<label>{address}</label>
</div>
);
// connect the state to component
const UserDetailsView = connect(mapStateToProps)(UserDetails);
Breaking changes:
- None