Releases: fatalxiao/vivy
Releases · fatalxiao/vivy
2.2.5
2.2.4
2.2.3
2.2.2
2.2.1
2.2.0
2.1.2
2.1.1
2.1.0
Add build-in model reducer setState
Use build-in model reducer setState
can easily dispatch a simple value updating action. Model reducer is no need written.
Vivy model
export default {
nameSpace: 'example',
state: {
value: ''
}
};
component
import React, {useCallback} from 'react';
import PropTypes from 'prop-types';
import {connect} from 'react-redux';
const Example = ({
value,
dispatch
}) => {
/**
* Update value to model
*/
const handleValueChange = useCallback(e => {
// Use build-in "setState reducer" update model state
dispatch?.({
type: 'example/setState',
nextState: state => ({
...state,
value: e?.target?.value
})
});
}, [
dispatch
]);
return (
<input value={value}
onChange={handleValueChange}/>
);
};
Example.propTypes = {
value: PropTypes.string,
dispatch: PropTypes.func
};
export default connect(state => ({
value: state.example.value
}))(Example);
Upgrades
- Add Validation
- Unit test
Improve examples
- calculation
- counter
- globalReducer
- requestApi
- pyramid