Use react+ ANTD-design and update it. Usually write an article hate themselves can not vomit things, this article is just the opposite, anyway, you can have to change after reading, no plus mian

Q1 Invalid Hook Call Warning

#321: Invalid Hook Call Warning. React official (reactjs.org/warnings/in… The possible causes of this error are as follows:

You might have mismatching versions of React and React DOM.

You might be breaking the Rules of Hooks.

You might have more than one copy of React in the same app
Copy the code

Each screen

React-dom and react are the same version as the react-DOM, which supports hooks syntax.Copy the code

This error does not exist in development mode. In particular, the webpack configuration used in our project is not the official scaffolding create-React-app, but the webpack configuration written by other developers. DLL was pre-packed before packaging. Take a look at the webpack.dll. Js prepackaged file, those familiar with WebPack configuration should be able to locate

const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');

/*********loaders***********/

/*********loaders***********/

/*********plugins***********/
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
var definePlugin = new webpack.DefinePlugin({
    "process.env": {
        NODE_ENV: JSON.stringify("production")}}); var providePlugin = new webpack.ProvidePlugin({ $:"jquery",
    jquery: "jquery"."windows.jQuery": "jquery",
    jQuery: "jquery"
});

const dllPlugin = new webpack.DllPlugin({
    path: path.join(__dirname, 'dll'.'manifest-[name].json'),
    name: '[name]'
});

const htmlWebpackPlugin = new HtmlWebpackPlugin(
    {
        title:"Cloud Livestock Innovation Platform",
        filename: '.. /template.html',
        template: './template-dll.html',
        favicon:"./favicon.ico".hash: true,
        chunks:["jquery"."react"."echarts"."bootstrap"."redux"]}); /*********plugins***********/ module.exports = { entry: { jquery:["jquery"],
        react:["react"."react-dom"."react-router-dom"],
        echarts:["echarts"],
        bootstrap:["bootstrap"."bootstrap-datepicker"],
        redux:["react-redux",redux","redux-saga","redux-saga/effects"]}, output: {path: path.join(__dirname, 'DLL '), publicPath: './ DLL /',// access path filename: '[name].js', /** * output.library * will be defined as window.${output.library}* In this example, it will be defined as' window.vendor_library '*/ library: '[name]'}, // optimization: {// minimizer: [new UglifyJsPlugin()], // }, plugins: [providePlugin, dllPlugin, htmlWebpackPlugin, definePlugin // The above compression file will generate a warning, this cancelation warning], mode:'production'};Copy the code

It doesn’t matter if you can’t see it, I’ll just decrypt it, the problem is here at the entrance,

 entry: {
        jquery:["jquery"],
        react:["react"."react-dom"."react-router-dom"],
        echarts:["echarts"],
        bootstrap:["bootstrap"."bootstrap-datepicker"],
        redux:["react-redux",redux","redux-saga","redux-saga/effects"]}Copy the code

React-redux is a react-dependent interface that generates two react instances when redux is added to the redux interface

This is the reason why I don’t like to write webpack configuration by myself. If there is a problem, I can only complete it by myself on the Internet. I can find a bunch of reference methods on the Internet by using scaffolding. I really don’t have the energy to be a Webpack configuration engineer anymore

Automatic memory of forms

A background management project, where the user management needs to create a user, and then open the new user form, the user name and password will be automatically filled in the login user name and password

The problem is that you can’t automatically fill in a bunch of autocomplete=”off” messages on the web, and verify by yourself that it doesn’t work either on the form or on the input field. Set autoComplete =”new-password”

3 Implement PDF preview function

React-pdf is a PDF plugin that allows users to download files with only 10 MB of memory. When I open a PDF file with 10 MB of memory, my browser says I’m out of memory.

Let’s just do it native

  1. The binary returned by the back end is converted to bloB
  2. Reuse window. URL. CreateObjectURL generated blobUrl (note window. URL. CreateObjectURL compatibility, ie 10 +)
  3. Then assign blobUrl to iframe