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

InputText: Typescript useRef types with new const instead of class components #6336

Open
dvpritzbuer opened this issue Apr 8, 2024 · 11 comments
Labels
Typescript Issue or pull request is *only* related to TypeScript definition
Milestone

Comments

@dvpritzbuer
Copy link
Contributor

dvpritzbuer commented Apr 8, 2024

Describe the bug

const ref = useRef<Stepper>(null); --> "'Stepper' refers to a value, but is being used as a type here. Did you mean 'typeof Stepper'?"

const ref = useRef<Panel>(null); --> works fine

Reproducer

https://stackblitz.com/edit/vitejs-vite-osrp8p?file=src%2FApp.tsx,package.json

PrimeReact version

10.6.2

React version

18.x

Language

TypeScript

Build / Runtime

Vite

Browser(s)

No response

Steps to reproduce the behavior

No response

Expected behavior

No response

@dvpritzbuer dvpritzbuer added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Apr 8, 2024
@melloware melloware added Status: In Progress Core Team is working on the issue or pull request and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Apr 8, 2024
@melloware
Copy link
Member

@dvpritzbuer can you wait until the next release I am pretty sure all of your issues you are reporting are already fixed.

@melloware melloware changed the title Typescript useRef types with new const instead of class components Stepper: Typescript useRef types with new const instead of class components Apr 8, 2024
@melloware melloware added this to the 10.6.3 milestone Apr 8, 2024
@dvpritzbuer
Copy link
Contributor Author

dvpritzbuer commented Apr 8, 2024

I mean my first issue today was not already fixed and why shouldn't you take my free feedback even if you just tag it with fixed in 10.6.3?

And this issue here is valid for all new components that use const instead of class (also tested it for IconField) and not only the Stepper!

But ok.. at least in short notice my other bugs as comment:

  • IconField export/import wrong ("primereact/iconfield/iconfield")
  • Stepper documentation example and stackblitz use wrong imports (@/components/lib... instead of primereact/)
  • IconField documentation example uses vue code instead of react

@melloware
Copy link
Member

IconField already fixed: #6271

What I was saying was in main many things have already been fixed related to Stepper, InputIcon, IconField.

@dvpritzbuer
Copy link
Contributor Author

Yeah that's fine, but it's a lot easier for me to just post an issue report instead of searching the code for possible fixes.
Maybe a rough estimate when 10.6.3 will release?

@melloware
Copy link
Member

i think this week sometime. I don't work for PrimeTek...

@gucal
Copy link
Contributor

gucal commented Apr 9, 2024

Hi there,
We plan to release 10.6.3 today.
Thank you for the feedback.

@gucal
Copy link
Contributor

gucal commented Apr 9, 2024

Hi,

With release 10.6.3 the issue should be fixed. If you notice that the issue persists, please ping me.

@gucal gucal closed this as completed Apr 9, 2024
@gucal gucal removed this from the 10.6.3 milestone Apr 9, 2024
@dvpritzbuer
Copy link
Contributor Author

dvpritzbuer commented Apr 9, 2024

@gucal
This error is not fixed - updated the linked stackblitz.

Also I recognized the original ticket description is not correct since Stepper doesn't have a ref and I just tested it initially with this component since this is a new const type definition.
The stackblitz is now based on InputText.

I have no perfect solution here for you since it would either require the user to write more code or to import another type.

But it would work with this line:
const inputRef2 = useRef<React.ElementRef<typeof InputText>>(null);

So either the user always writes this line himself if using refs within typescript or you export another type like export const type InputTextRef = React.ElementRef<typeof InputText>; and the user has to use this new type then.

Maybe you find a better solution here?

@melloware melloware reopened this Apr 9, 2024
@melloware melloware added Type: Bug Issue contains a defect related to a specific component. and removed Status: In Progress Core Team is working on the issue or pull request labels Apr 9, 2024
@github-actions github-actions bot added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Apr 9, 2024
@melloware melloware changed the title Stepper: Typescript useRef types with new const instead of class components InputText: Typescript useRef types with new const instead of class components Apr 9, 2024
@melloware melloware added Typescript Issue or pull request is *only* related to TypeScript definition and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible Type: Bug Issue contains a defect related to a specific component. labels Apr 9, 2024
@melloware
Copy link
Member

Reopened and changed the title.

@gucal gucal added this to the 10.6.4 milestone Apr 9, 2024
@dvpritzbuer
Copy link
Contributor Author

Ah sorry, I got confused by changing the types within PR #6356 and Stepper not having any ref definition yet, but of course the Stepper also has a ref and the initial title was valid 😅

@nitrogenous nitrogenous modified the milestones: 10.6.4, Future Apr 30, 2024
@melloware
Copy link
Member

@dvpritzbuer i am confused where are we at with this ticket as of 10.6.5?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Typescript Issue or pull request is *only* related to TypeScript definition
Projects
None yet
Development

No branches or pull requests

4 participants