Skip to content

Commit

Permalink
✨ throw an error when React 17 is used with the React 18 version
Browse files Browse the repository at this point in the history
  • Loading branch information
astoilkov committed Aug 9, 2022
1 parent 9b791e4 commit e6cf1ad
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/useLocalStorageState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ export default function useLocalStorageState<T = undefined>(
key: string,
options?: LocalStorageOptions<T | undefined>,
): LocalStorageState<T | undefined> {
if (typeof useSyncExternalStore === 'undefined') {
throw new TypeError(
`You are using React 17 or below. Install use-local-storage-state with "npm install use-local-storage-state@17".`,
)
}

const defaultValue = options?.defaultValue

// SSR support
Expand Down

0 comments on commit e6cf1ad

Please sign in to comment.