Closed lizheming closed 5 years ago
As documentation said, useCallback should always return a memoized callback. Here is an example that different between React and Anujs:
useCallback
<script src="https://unpkg.com/anujs@1.5.6/dist/React.js"></script> <div id="app"></div> <script> const App = () => { const [count, up] = React.useState(1); const fn = React.useCallback(() => count + 10, []); const onClick = () => up(count + 1); return ( <React.Fragment> <button onClick={onClick}>click me</button> <div>{`count value:${count},count value after plus:${fn()}`}</div> </React.Fragment> ); } ReactDOM.render(<App />, document.getElementById('app')); </script>
The reason why it returns error is that #1083 pull request fix to return undefined when deps equals, that's all my fault. So I revert #1083 pull request and change useEffectImpl method to avoid #1067 problem.
useEffectImpl
As documentation said,
useCallback
should always return a memoized callback. Here is an example that different between React and Anujs:The reason why it returns error is that #1083 pull request fix to return undefined when deps equals, that's all my fault. So I revert #1083 pull request and change
useEffectImpl
method to avoid #1067 problem.