New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-umi-model

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-umi-model

Auto-completion of the callback function in useModel.

  • 1.0.1
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

babel-plugin-umi-model

This plugin is used to automatically introduce the second parameter in umi's useModel, removing the unused value and avoiding the performance loss caused by repeated rendering of the component.

NPM version

English | 简体中文

📦 Install

npm i babel-plugin-umi-model --save-dev

or

pnpm add babel-plugin-umi-model -D

🔨 Usage

import { useModel } from "umi";

const { userInfo, token } = useModel("user");

⬇️

import { useModel } from "umi";

const { userInfo, token } = useModel("user", (model) => ({
  userInfo: model.userInfo,
  token: model.token,
}));

🖥 Config

1. .babelrc

This configuration is common to umi3 and umi4 versions

Remember to configure the .env file with BABELRC=true

{
  "plugins": [
    "umi-model"
  ]
}

2. extraBabelPlugins

This configuration is common to umi3 and umi4 versions

import { defineConfig } from "umi";
// import BabelPluginUmiModel from 'babel-plugin-umi-model'

export default defineConfig({
  extraBabelPlugins: [
    "umi-model",
    // [
    //   "umi-model",
    //     {
    //       extensions: [".jsx", ".tsx"],
    //       excludes: ['node_modules', 'src/.umi', 'src/.umi-production'],
    //     },
    //   ],
    // ],
    // BabelPluginUmiModel
  ],
});

3. plugins

umirc.js
import { defineConfig } from "umi";

export default defineConfig({
  plugins: ["./plugin-test"],
});
plugin-test.ts
import { IApi } from "umi";

export default (api: IApi) => {
  api.addBeforeBabelPlugins(() => {
    return ["umi-model"];
  });
};

Options

extensions

  • Type: string[]
  • Default: ['.jsx', '.tsx']

excludes

  • Type: string[]
  • Default: ['node_modules', 'src/.umi', 'src/.umi-production']

Keywords

FAQs

Package last updated on 30 Dec 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc