🎥 Make videos programmatically with React
why a string?
Jonny Burger6253a3e26344
diff --git a/packages/studio/src/components/NewComposition/DuplicateComposition.tsx b/packages/studio/src/components/NewComposition/DuplicateComposition.tsxindex 84ba31a3c4..a227edbe16 100644--- a/packages/studio/src/components/NewComposition/DuplicateComposition.tsx+++ b/packages/studio/src/components/NewComposition/DuplicateComposition.tsx@@ -51,9 +51,7 @@ const DuplicateCompositionLoaded: React.FC<{}> = () => {const hadFpsDefined = unresolved.fps !== undefined;const hadDurationDefined = unresolved.durationInFrames !== undefined;- const [selectedFrameRate, setFrameRate] = useState<string>(- String(resolved.result.fps),- );+ const [selectedFrameRate, setFrameRate] = useState(resolved.result.fps);const {compositions} = useContext(Internals.CompositionManager);const [type, setType] = useState<CompType>(initialCompType);const [newId, setName] = useState(() => {@@ -78,11 +76,13 @@ const DuplicateCompositionLoaded: React.FC<{}> = () => {});const [size, setSize] = useState(() => ({- width: String(resolved.result.width),- height: String(resolved.result.height),+ width: resolved.result.width,+ height: resolved.result.height,}));- const [durationInFrames, setDurationInFrames] = useState('150');+ const [durationInFrames, setDurationInFrames] = useState(+ resolved.result.durationInFrames,+ );const onTypeChanged = useCallback((newType: CompType) => {setType(newType);@@ -94,7 +94,7 @@ const DuplicateCompositionLoaded: React.FC<{}> = () => {const newWidth = Number(newValue);return {height,- width: String(newWidth),+ width: newWidth,};});}, []);@@ -105,7 +105,7 @@ const DuplicateCompositionLoaded: React.FC<{}> = () => {return {height,- width: String(newWidth),+ width: newWidth,};});}, []);@@ -116,7 +116,7 @@ const DuplicateCompositionLoaded: React.FC<{}> = () => {return {width,- height: String(newHeight),+ height: newHeight,};});}, []);@@ -127,7 +127,7 @@ const DuplicateCompositionLoaded: React.FC<{}> = () => {const newHeight = Number(newValue);return {width,- height: String(newHeight),+ height: newHeight,};});}, []);@@ -139,11 +139,11 @@ const DuplicateCompositionLoaded: React.FC<{}> = () => {[],);const onTextFpsChange = useCallback((newFps: string) => {- setFrameRate(String(newFps));+ setFrameRate(Number(newFps));}, []);const onFpsChange = useCallback((newFps: number) => {- setFrameRate(String(newFps));+ setFrameRate(newFps);}, []);const compNameErrMessage = validateCompositionName(newId, compositions);diff --git a/packages/studio/src/components/NewComposition/NewCompDuration.tsx b/packages/studio/src/components/NewComposition/NewCompDuration.tsxindex 522675ec88..412d387ee1 100644--- a/packages/studio/src/components/NewComposition/NewCompDuration.tsx+++ b/packages/studio/src/components/NewComposition/NewCompDuration.tsx@@ -6,19 +6,19 @@ import {InputDragger} from './InputDragger';import {ValidationMessage} from './ValidationMessage';export const NewCompDuration: React.FC<{- durationInFrames: string;- setDurationInFrames: React.Dispatch<React.SetStateAction<string>>;+ durationInFrames: number;+ setDurationInFrames: React.Dispatch<React.SetStateAction<number>>;}> = ({durationInFrames, setDurationInFrames}) => {const onDurationInFramesChanged = useCallback((newValue: string) => {- setDurationInFrames(String(Number(newValue)));+ setDurationInFrames(Number(newValue));},[setDurationInFrames],);const onDurationChangedDirectly = useCallback((newVal: number) => {- setDurationInFrames(String(newVal));+ setDurationInFrames(newVal);},[setDurationInFrames],);diff --git a/packages/studio/src/helpers/validate-new-comp-data.ts b/packages/studio/src/helpers/validate-new-comp-data.tsindex 05664b9c02..0ca63dd571 100644--- a/packages/studio/src/helpers/validate-new-comp-data.ts+++ b/packages/studio/src/helpers/validate-new-comp-data.ts@@ -18,7 +18,7 @@ export const validateCompositionName = (export const validateCompositionDimension = (dimension: 'Width' | 'Height',- value: string,+ value: number,): string | null => {if (Number(value) % 2 !== 0) {return `${dimension} should be divisible by 2, since H264 codec doesn't support odd dimensions.`;@@ -35,16 +35,16 @@ export const validateCompositionDimension = (return null;};-export const validateCompositionDuration = (value: string): string | null => {- if (Number(value) % 1 !== 0) {+export const validateCompositionDuration = (value: number): string | null => {+ if (value % 1 !== 0) {return `Duration must be an integer.`;}- if (Number.isNaN(Number(value))) {+ if (Number.isNaN(value)) {return 'Invalid number.';}- if (Number(value) === 0) {+ if (value === 0) {return 'Duration cannot be zero.';}