Skip to content

Commit

Permalink
Multiple FileRef calls creates infinite loop error Fixes #96 (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
joegasewicz committed Jan 20, 2021
1 parent 3fcbc50 commit 7bcc663
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 9 additions & 0 deletions showcase/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
interface IProps{}

const myFileRef = createFileRef();
const myFileRef2 = createFileRef();

interface IState{

Expand Down Expand Up @@ -100,6 +101,7 @@ export class Main extends React.Component<IProps, IState> {
radio3: false,
fruitChoice: "",
myFileTest: getFileFromRef(myFileRef),
myFileTest2: getFileFromRef(myFileRef2),
}

};
Expand Down Expand Up @@ -184,6 +186,13 @@ export class Main extends React.Component<IProps, IState> {
name="myFileTest"
validators={[isFile()]}
/>
<FileField
ref={myFileRef2}
hint="Must be a file"
labelText="Upload your file"
name="myFileTest"
validators={[isFile()]}
/>

<RadioGroup name="group1">
<RadioField
Expand Down
4 changes: 3 additions & 1 deletion src/core/_MetadataFile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ export class MetadataFile<T extends IFieldValidation> extends AbstractMetadata<T
isTouched: true,
},
};
this.updateState(state);
useEffect(() => {
this.updateState(state);
}, [state]);
}
}
}
Expand Down

0 comments on commit 7bcc663

Please sign in to comment.