common.js 287 B

123456789101112
  1. import { useModel } from 'umi';
  2. export function connectModel(key, name) {
  3. return function (WrappedComponent) {
  4. return function (props) {
  5. const model = useModel(name);
  6. const data = { [key]: model };
  7. return <WrappedComponent {...props} {...data} />;
  8. };
  9. };
  10. }