Skip to content

Commit

Permalink
Merge pull request #35 from dai-shi/avoid-warning-in-ssr
Browse files Browse the repository at this point in the history
avoid warning in ssr
  • Loading branch information
dai-shi committed Nov 28, 2019
2 parents 0862177 + 4861077 commit e0a61bc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -3,6 +3,7 @@
## [Unreleased]
### Changed
- Fix useAsyncCombineRace which was totally broken in v3.8.0
- Do not useLayoutEffect which shows warning in SSR (#35)

## [3.8.0] - 2019-11-26
### Changed
Expand Down
6 changes: 3 additions & 3 deletions src/use-async-task.js
@@ -1,4 +1,4 @@
import { useLayoutEffect, useReducer, useRef } from 'react';
import { useEffect, useReducer, useRef } from 'react';

const createTask = ({ func, dispatchRef }) => {
const taskId = Symbol('TASK_ID');
Expand Down Expand Up @@ -98,8 +98,8 @@ export const useAsyncTask = (func) => {
if (task.func !== func) {
dispatch({ type: 'INIT', func, dispatchRef });
}
useLayoutEffect(() => {
dispatchRef.current = dispatch;
dispatchRef.current = dispatch;
useEffect(() => {
const cleanup = () => {
dispatchRef.current = () => {};
};
Expand Down

0 comments on commit e0a61bc

Please sign in to comment.