Skip to content

Commit

Permalink
Fix warning with fetchPriority (closes #100)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanoverna committed Jun 12, 2024
1 parent 26dac2f commit 4b3d0f5
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/SRCImage/utils.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
import React, { version } from 'react';
import React from 'react';
import type { ResponsiveImageType } from '../Image';

export function priorityProp(
fetchPriority?: string,
): Record<string, string | undefined> {
const [majorStr, minorStr] = version.split('.');
const major = Number.parseInt(majorStr, 10);
const minor = Number.parseInt(minorStr, 10);

// https://github.com/vercel/next.js/commit/68d5a3892b4edf1b62e3ece4ada324065a96b6f3
if (major > 18) {

// biome-ignore lint/suspicious/noExplicitAny: React.use is only available on React 19, react@canary and react@beta
if (typeof (React as any).use === 'function') {
return { fetchPriority };
}
// In React 18.2.0 or older, we must use lowercase prop
// to avoid "Warning: Invalid DOM property".

return { fetchpriority: fetchPriority };
}

Expand Down

0 comments on commit 4b3d0f5

Please sign in to comment.