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

Imports are not working / @mui/base not working anymore #37376

Closed
2 tasks done
Stophface opened this issue May 23, 2023 · 4 comments
Closed
2 tasks done

Imports are not working / @mui/base not working anymore #37376

Stophface opened this issue May 23, 2023 · 4 comments
Labels
package: base-ui Specific to @mui/base status: expected behavior Does not imply the behavior is intended. Just that we know about it and can't work around it

Comments

@Stophface
Copy link

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Steps to reproduce 🕹

Link to live example:
https://mui.com/material-ui/react-autocomplete/#useautocomplete (taken from here: https://mui.com/material-ui/react-autocomplete/#useautocomplete)
https://codesandbox.io/s/vfq40l?file=/demo.tsx (taken from here: https://mui.com/base/react-select/#hooks)

Current behavior 😯

I am trying to work with @mui/base in a TypeScript project, which is breaking on me. These are the versions I installed

"@mui/base": "^5.0.0-alpha.115",
"@mui/material": "^5.11.13",

However, as soon as I try to import something I get various error messages

import {useAutocomplete} from '@mui/base/AutocompleteUnstyled';

Can't resolve '@mui/base/AutocompleteUnstyled'

import {useSelect, SelectOption} from '@mui/base';
const {
    getButtonProps,
    getListboxProps,
    getOptionProps,
    getOptionState,
} = useSelect({
    listboxRef,
    onOpenChange: setListBoxVisible,
    onChange: (event, value) => setValue(options.filter(option => option.value === value)),
    open: listBoxVisible,
    options,
    value
});

This highlights getOptionProps, getOptionState with the message

Property 'getOptionProps' does not exist on type 'UseSelectReturnValue '.
Property 'getOptionState' does not exist on type 'UseSelectReturnValue '.

So the examples in the documentation do not work anymore... Why is that?

Expected behavior 🤔

I expect the imports to work as stated in the documentation as well as the code.

Context 🔦

No response

Your environment 🌎

npx @mui/envinfo
   System:
    OS: Windows 10 10.0.22621
  Binaries:
    Node: 18.12.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 8.19.2 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: Not Found
    Edge: Spartan (44.22621.1702.0), Chromium (113.0.1774.42)
  npmPackages:
    @emotion/react: ^11.10.6 => 11.11.0
    @emotion/styled: ^11.10.6 => 11.11.0
    @mui/base: ^5.0.0-alpha.115 => 5.0.0-beta.2
    @mui/core-downloads-tracker:  5.13.2
    @mui/material: ^5.11.13 => 5.13.2
    @mui/private-theming:  5.13.1
    @mui/styled-engine:  5.13.2
    @mui/system:  5.13.2
    @mui/types:  7.2.4
    @mui/utils:  5.13.1
    @types/react: ^18.2.6 => 18.2.6
    react: ^18.2.0 => 18.2.0
    react-dom: ^18.2.0 => 18.2.0
    styled-components: ^5.3.9 => 5.3.10
    typescript: ^4.9.5 => 4.9.5

Working with firefox

@Stophface Stophface added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label May 23, 2023
@hbjORbj
Copy link
Member

hbjORbj commented May 23, 2023

Can't resolve '@mui/base/AutocompleteUnstyled'

'@mui/base/Autocomplete' is correct as we removed the Unstyled suffix. This breaking change was introduced in this PR.

You can use this codemod to help with the migration:

npx @mui/codemod v5.0.0/base-remove-unstyled-suffix <path>

@hbjORbj hbjORbj added package: base-ui Specific to @mui/base and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels May 23, 2023
@Stophface
Copy link
Author

@hbjORbj Thanks, I understand.
That does not explain why I am getting this TypeScript Compiler error though

import {useSelect, SelectOption} from '@mui/base';
const {
    getButtonProps,
    getListboxProps,
    getOptionProps,
    getOptionState,
} = useSelect({
    listboxRef,
    onOpenChange: setListBoxVisible,
    onChange: (event, value) => setValue(options.filter(option => option.value === value)),
    open: listBoxVisible,
    options,
    value
});

The compiler highlights getOptionProps, getOptionState with the message

Property 'getOptionProps' does not exist on type 'UseSelectReturnValue '.
Property 'getOptionState' does not exist on type 'UseSelectReturnValue '.

@hbjORbj
Copy link
Member

hbjORbj commented May 25, 2023

I do not see TS error in the codesandbox you provided.
Screenshot 2023-05-25 at 11 55 39

@hbjORbj hbjORbj self-assigned this May 25, 2023
@michaldudak
Copy link
Member

@Stophface, these fields were removed from useSelect's return type. Now, a useOption hook can be used to get options' props and state.

@michaldudak michaldudak closed this as not planned Won't fix, can't repro, duplicate, stale Jun 23, 2023
@michaldudak michaldudak added the status: expected behavior Does not imply the behavior is intended. Just that we know about it and can't work around it label Jun 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: base-ui Specific to @mui/base status: expected behavior Does not imply the behavior is intended. Just that we know about it and can't work around it
Projects
None yet
Development

No branches or pull requests

3 participants