Skip to content
Discussion options

You must be logged in to vote

I overlooked another aspect of how your file input is connected to RHF. You are spreading the return values of the register method and subsequently replacing the onChange input callback with your custom handleFileInputChange. This might be the reason for th behavior you're seeing. To prevent overriding the onChange callback from the returned register values, use the onChange callback prop in the second options argument of the register method.

{...register("fieldName", { onChange: handleFileInputChange })}

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@6vvvvvv
Comment options

@Moshyfawn
Comment options

@6vvvvvv
Comment options

@Moshyfawn
Comment options

Answer selected by 6vvvvvv
@6vvvvvv
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants