Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: replace useCallback with useHandler #1779

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

chenzn1
Copy link
Contributor

@chenzn1 chenzn1 commented Feb 15, 2023

Types of changes

  • New feature
  • Bug fix
  • Enhancement
  • Documentation change
  • Coding style change
  • Component style change
  • Refactoring
  • Test cases
  • Continuous integration
  • Typescript definition change
  • Breaking change
  • Others

Background and context

Solution

How is the change tested?

Changelog

Component Changelog(CN) Changelog(EN) Related issues
Anchor 使用 useHandler 替换 useCallback replace useCallback with useHandler #1776

Checklist:

  • Test suite passes (npm run test)
  • Provide changelog for relevant changes (e.g. bug fixes and new features) if applicable.
  • Changes are submitted to the appropriate branch (e.g. features should be submitted to feature branch and others should be submitted to main branch)

Other information

@chenzn1 chenzn1 changed the title refactor: replace useCallback with useHandler refactor: replace useCallback with useHandler Feb 15, 2023
@chenzn1 chenzn1 force-pushed the refactor/use-callback branch 2 times, most recently from b3036cb to b7567a8 Compare February 15, 2023 11:06
@chenzn1
Copy link
Contributor Author

chenzn1 commented Feb 15, 2023

先改 Anchor ,如果可以的话,后面再替换其它地方。

@github-actions
Copy link

Prepare preview

@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 4372b66:

Sandbox Source
arco-react-pr-template Configuration

@yinkaihui
Copy link
Contributor

https://codesandbox.io/s/rough-night-qvjs72?file=/demo.js 这种写法好像在这个场景里有问题?

@chenzn1
Copy link
Contributor Author

chenzn1 commented Mar 17, 2023

https://codesandbox.io/s/rough-night-qvjs72?file=/demo.js 这种写法好像在这个场景里有问题?

fnRef.current.fn 初始化那里写错了

const fnRef = useRef({
    originalFn: fn,
    fn: (...args) => {
      return fnRef.current.originalFn.apply(undefined, args)
    }
  });

这样才可以
@yinkaihui

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants