Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NumericFormatの話 #1

Open
AoSankaku opened this issue Dec 4, 2023 · 0 comments
Open

NumericFormatの話 #1

AoSankaku opened this issue Dec 4, 2023 · 0 comments
Labels
Article Idea 記事のアイデア

Comments

@AoSankaku
Copy link
Owner

const [borrowAmount, setBorrowAmount] = useState(0);
  const BorrowInput = () => {
    return (
      <>
        <NumericFormat
          required
          value={borrowAmount}
          customInput={TextField}
          id="outlined-start-adornment55555555555555555555"
          sx={{ width: 'auto', m: 1, minWidth: 120 }}
          label="金額2"
          thousandSeparator=","
          decimalScale={0}
          prefix={'¥ '}
          inputProps={{
            inputMode: 'numeric'
          }}
          onValueChange={(v) => {
            setBorrowAmount(v.floatValue);
          }}
        />
        <Typography variant="h6" gutterBottom style={{ marginTop: "30px" }}>
          {borrowAmount}
        </Typography>
      </>
    )
  }
//...

は再描画問題を起こすが、

//親レベル
  const BorrowInput = () => {
    const [borrowAmount, setBorrowAmount] = useState(0);
    return (
      <>
        <NumericFormat
          required
          value={borrowAmount}
          customInput={TextField}
          id="outlined-start-adornment55555555555555555555"
          sx={{ width: 'auto', m: 1, minWidth: 120 }}
          label="金額2"
          thousandSeparator=","
          decimalScale={0}
          prefix={'¥ '}
          inputProps={{
            inputMode: 'numeric'
          }}
          onValueChange={(v) => {
            setBorrowAmount(v.floatValue);
          }}
        />
        <Typography variant="h6" gutterBottom style={{ marginTop: "30px" }}>
          {borrowAmount}
        </Typography>
      </>
    )
  }
//...

は再描画問題を起こさないという話

@AoSankaku AoSankaku added the Article Idea 記事のアイデア label Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Article Idea 記事のアイデア
Projects
None yet
Development

No branches or pull requests

1 participant