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

avoid warning in ssr #35

Merged
merged 3 commits into from Nov 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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