Skip to content

Instantly share code, notes, and snippets.

@weikee94
Created November 20, 2015 02:15
Show Gist options
  • Select an option

  • Save weikee94/ecb022f11bbeda36a763 to your computer and use it in GitHub Desktop.

Select an option

Save weikee94/ecb022f11bbeda36a763 to your computer and use it in GitHub Desktop.
@weikee94
Copy link
Copy Markdown
Author

weikee94 commented Jan 17, 2023

axios tips

// sending api checking
{
        test_id: 1
        ...(queryValue?.test=== 'no' && {
          area: queryValue?.test.replaceAll(' ', '').split(','),
        }),
      },

@weikee94
Copy link
Copy Markdown
Author

weikee94 commented Feb 3, 2023

const updateValue = (i, c) => {
    // setValueText(c);
    list.map((item, index) => {
      if (index === i) {
        item.fieldValue = c;
      }
    });
    setList(list);
  };

  const addListItem = () => {
    // setNameText('');
    // setValueText('');
    setList([...list, { fieldName: '', fieldValue: '' }]);
    // setEmptyError(false);
  };

@weikee94
Copy link
Copy Markdown
Author

Commitlint setup

Install commitlint cli and conventional config

npm install --save-dev @commitlint/config-conventional @commitlint/cli

Configure commitlint to use conventional config

echo "module.exports = {extends: ['@commitlint/config-conventional']}" > commitlint.config.js

Install Husky v6

npm install husky --save-dev

Activate hooks

npx husky install

Add hook for lint-staged and commitlint

npx husky add .husky/commit-msg 'npx lint-staged && npx --no -- commitlint --edit ${1}'

@weikee94
Copy link
Copy Markdown
Author

How to reset

Project directory check hooksPath
cat .git/config
Reset the hooksPath every file inside ".git/hooks/" is either a git-hook or ignored by git. By removing everything inside, you'll get rid of all hooks, and restore the default behavior.
npm uninstall husky && git config --unset core.hooksPath

@weikee94
Copy link
Copy Markdown
Author

weikee94 commented Apr 25, 2023

Interval

  useEffect(() => {
    const interval = setInterval(() => {
      getList(
        {
          limit: pageState?.pageSize, // 分页获取数量
          page: pageState?.pageNum,
        },
      );
    }, 60000);

    return () => {
      clearInterval(interval);
    };
  }, [pageState]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment