Skip to content
This repository was archived by the owner on Nov 24, 2025. It is now read-only.
This repository was archived by the owner on Nov 24, 2025. It is now read-only.

Allow decimals = 0 #10

@lmcorbalan

Description

@lmcorbalan

If you set decimals prop as 0 an error is thrown as soon as you write a number in the input.
The problem seems to be in the following useEffect:

React.useEffect(() => {
    if (!value) {
      setInputvalue('')
    } else if (!parseUnits(inputValue || '0', decimals).eq(value)) {
      setInputvalue(formatUnits(value, decimals))
    }
  }, [value, decimals, inputValue])

formatUnits(value, 0) returns value.0 then the useEffect is executed again as inputValue is updated, then parseUnits('valu.0', decimals) throws the error

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions