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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OutlinedInput] ownerState can be undefined momentarily #32710

Closed
2 tasks done
vimutti77 opened this issue May 10, 2022 · 1 comment
Closed
2 tasks done

[OutlinedInput] ownerState can be undefined momentarily #32710

vimutti77 opened this issue May 10, 2022 · 1 comment
Assignees
Labels
bug 馃悰 Something doesn't work duplicate This issue or pull request already exists package: system Specific to @mui/system

Comments

@vimutti77
Copy link
Contributor

vimutti77 commented May 10, 2022

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 馃槸

Get Cannot read properties of undefined error

Expected behavior 馃

The default value of ownerState should be empty object {}. Or change the type of ownerState to be optional

Steps to reproduce 馃暪

Steps:

  1. open https://codesandbox.io/s/usage-forked-dob3eo?file=/index.tsx

Context 馃敠

Im using no-unnecessary-condition eslint rule to check if I should use optional chaining (?.)

And because the type of ownerState is non-undefined, eslint tell me to not use optional chaining (?.)

But when I remove ?., I got Cannot read properties of undefined error.

Your environment 馃寧

`npx @mui/envinfo`
  System:
    OS: Windows 10 10.0.22000
  Binaries:
    Node: 16.13.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.15 - C:\Program Files\nodejs\yarn.CMD
    npm: 8.1.2 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: Not Found
    Edge: Spartan (44.22000.120.0), Chromium (101.0.1210.39)
  npmPackages:
    @emotion/react: ^11.9.0 => 11.9.0 
    @emotion/styled: ^11.8.1 => 11.8.1
    @mui/base:  5.0.0-alpha.79
    @mui/icons-material: ^5.6.2 => 5.6.2
    @mui/lab: ^5.0.0-alpha.80 => 5.0.0-alpha.80
    @mui/material: ^5.6.4 => 5.6.4
    @mui/private-theming:  5.6.2
    @mui/styled-engine:  5.6.1
    @mui/system:  5.6.4
    @mui/types:  7.1.3
    @mui/utils:  5.6.1
    @mui/x-data-grid: ^5.10.0 => 5.10.0
    @mui/x-data-grid-pro: ^5.10.0 => 5.10.0
    @mui/x-date-pickers:  5.0.0-alpha.0
    @mui/x-license-pro:  5.10.0
    @types/react: ^18.0.9 => 18.0.9
    react: ^18.1.0 => 18.1.0
    react-dom: ^18.1.0 => 18.1.0
    typescript: ^4.6.4 => 4.6.4
@vimutti77 vimutti77 added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label May 10, 2022
@hbjORbj hbjORbj changed the title ownerState can be undefined, but its type is non-undefined [OutlinedInput] ownerState can be undefined momentarily May 10, 2022
@hbjORbj hbjORbj added bug 馃悰 Something doesn't work package: system Specific to @mui/system labels May 10, 2022
@ZeeshanTamboli
Copy link
Member

Duplicate of #31982

@ZeeshanTamboli ZeeshanTamboli marked this as a duplicate of #31982 May 11, 2022
@siriwatknp siriwatknp added duplicate This issue or pull request already exists and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels May 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 馃悰 Something doesn't work duplicate This issue or pull request already exists package: system Specific to @mui/system
Projects
None yet
Development

No branches or pull requests

5 participants