🎥 Make videos programmatically with React
update validation
Jonny Burger80e6563d7662
diff --git a/packages/core/src/freeze.tsx b/packages/core/src/freeze.tsxindex e0edbf1695..a24237e5e7 100644--- a/packages/core/src/freeze.tsx+++ b/packages/core/src/freeze.tsx@@ -6,9 +6,27 @@ type FreezeProps = {};const Freeze: React.FC<FreezeProps> = ({frame, children}) => {+ if (typeof frame === 'undefined') {+ throw new Error(+ `The <Freeze /> component requires a 'frame' prop, but none was passed.`+ );+ }+if (typeof frame !== 'number') {throw new Error(- `You passed to 'frame' an argument of type ${typeof frame}, but it must be a number.`+ `The 'frame' prop of <Freeze /> must be a number, but is of type ${typeof frame}`+ );+ }++ if (Number.isNaN(frame)) {+ throw new Error(+ `The 'frame' prop of <Freeze /> must be a real number, but it is NaN.`+ );+ }++ if (!Number.isFinite(frame)) {+ throw new Error(+ `The 'frame' prop of <Freeze /> must be a finite number, but it is ${frame}.`);}diff --git a/packages/core/src/test/freeze.test.tsx b/packages/core/src/test/freeze.test.tsxindex 030a481b61..3c07fbb756 100644--- a/packages/core/src/test/freeze.test.tsx+++ b/packages/core/src/test/freeze.test.tsx@@ -7,14 +7,14 @@ describe('Throw with invalid duration props', () => {expectToThrow(// @ts-expect-error() => render(<Freeze frame={'0'} />),- /You passed to 'frame' an argument of type string, but it must be a number./+ /The 'frame' prop of <Freeze \/> must be a number, but is of type string/);});test('It should throw if Freeze has undefined as frame prop value', () => {expectToThrow(// @ts-expect-error() => render(<Freeze />),- /You passed to 'frame' an argument of type undefined, but it must be a number./+ /The <Freeze \/> component requires a 'frame' prop, but none was passed./);});});