Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "uncrontrolled"

Index

Functions

createFileRef

  • createFileRef(): RefObject<HTMLFormElement>
  • RBF's provides a function that returns a React ref to access your file object. To use, simply assign the returned ref from the createFileRef function to a variable & pass this variable to FileField's ref prop.

    example
    
     import {createFileRef, FileField, isFile, getFileFromRef} from "react-bare-forms";
    
     const myFileRef = createFileRef();
    
     <FileField
        ref={myFileRef}
        hint="Must be a file"
        labeltext="Upload your file"
        name="myFileTest"
        validators={[isFile()]}
     />
    

    Returns RefObject<HTMLFormElement>

getFileFromRef

  • getFileFromRef(fileRef: RefObject<HTMLFormElement>): IFile | null
  • To get a file object back from the react ref, you can use getFileFromRef function.

    params

    The React ref returned from createFileRef

    example
    
     import {createFileRef, FileField, isFile, getFileFromRef} from "react-bare-forms";
    
     const myFileRef = createFileRef();
    
     <FileField
        ref={myFileRef}
        hint="Must be a file"
        labelrext="Upload your file"
        name="myFileTest"
        validators={[isFile()]}
     />
    
     let fileData = {
         myFile: getFileFromRef(myFileRef)
     };
    
     // fileData.myFile is your Javascript File object.
    

    Parameters

    • fileRef: RefObject<HTMLFormElement>

    Returns IFile | null

Generated using TypeDoc