I am using useForm hook produced by React Hook Form library. Because of the UI library that I use I am forced to create custom radio buttons. My problem is that even i have a type in interface that defines the form when I try to register two components of same name I am getting an warning that says:
'Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?
Check the render method of `NewForm`.
at ToggleButton (http://localhost:3000/static/js/main.chunk.js:1236:23)'
Here is the interface and type:
interface FormInput {
dynamicFieldTitle: string;
formTitle: string;
tokenType: TokenType;
tokenAddress: string;
tokenId: string;
expirationDate: string;
}
type TokenType = "ERC1155" | "ERC721";
And here is the JSX code:
<ToggleButton
{...register("tokenType")}
onClick={toggleButtonHandler}
position="left"
selected={!isERC1155}
>
ERC721
</ToggleButton>
<ToggleButton
{...register("tokenType")}
onClick={toggleButtonHandler}
position="right"
selected={isERC1155}
>
ERC1155
</ToggleButton>