You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my system i have an object with 2 dropdown, we can see the page in the image below:
Each dropdown is an object. The first named categoriaProduto and second named fornecedor. Below the objects interface:
CategoriaProduto
export interface ICategoriaProduto {
id: number
descricao: string
status: boolean
}
The 2 objects have a method to return a valid instance of the object. This instance have a simple values id (like a code in english) equals 0 (zero), descricao (description in english) equals '' and status equals true or false.
I have a principal object named ProdutoAtendimento. ProdutoAtendimento have some properties and 2 of this properties are categoriaProduto and fornecedor. Below we can see the object ProdutoAtendimento:
In component, i just have a dropdown using ProdutoAtendimento object and the properties categoriaProduto and fornecedor:
So, in the new version of primereact, 10.7.0, when i create an instance of categoriaProduto or fornecedor with the description equals a empty string like '' i got the error below:
When i chance the properties description to any string value like 'test', the component works fine.
Thats the problem, '' is a valid string to init my component and its works fine in 10.6.6 versions and all versions.
So, to fix my application i need to go to categoriaProduto and fornecedor objects and change de instance method to use a fake value in descricao properties to my app works.
export const initCategoriaProduto = (): ICategoriaProduto => ({
id: 0,
descricao: 'test', //i put this fake value here and "fix" the problem
status: false
})
export const initFornecedor = (): IFornecedor => ({
id: 0,
descricao: 'test', //i put this fake value here and "fix" the problem
status: true
})
Even though my paleative solution works, it still seems like a bug in the Dropdown component.
and it always worked in previous versions
Reproducer
No response
PrimeReact version
10.7.0
React version
18.x
Language
TypeScript
Build / Runtime
Next.js
Browser(s)
No response
Steps to reproduce the behavior
When you use a default value to an object with de description propertie with the default value equals an empty string like "", the dropdown component don't work. and it always worked in previous versions.
i put a fake value to "fix" my problem:
{
id: 0,
descricao: 'test', // fake value here to fix my problem
status: true
}
Expected behavior
The dropdown component needs to work, with a default value like the object below:
{
id: 0,
descricao: '',
status: true
}
The text was updated successfully, but these errors were encountered:
I have the same problem. Long story short - if the label on any of the options object is an empty string - Dropdown crashes with the error when clicking on it (trying to open it):
Error: Objects are not valid as a React child (found: object with keys {value, label}). If you meant to render a collection of children, use an array instead.
melloware
added
Type: Bug
Issue contains a defect related to a specific component.
and removed
Status: Needs Triage
Issue will be reviewed by Core Team and a relevant label will be added as soon as possible
labels
Jul 11, 2024
Describe the bug
In my system i have an object with 2 dropdown, we can see the page in the image below:
Each dropdown is an object. The first named categoriaProduto and second named fornecedor. Below the objects interface:
CategoriaProduto
export interface ICategoriaProduto {
id: number
descricao: string
status: boolean
}
export const initCategoriaProduto = (): ICategoriaProduto => ({
id: 0,
descricao: '',
status: false
})
Fornecedor:
export interface IFornecedor {
id: number
descricao: string
status: boolean
}
export const initFornecedor = (): IFornecedor => ({
id: 0,
descricao: '',
status: true
})
The 2 objects have a method to return a valid instance of the object. This instance have a simple values id (like a code in english) equals 0 (zero), descricao (description in english) equals '' and status equals true or false.
I have a principal object named ProdutoAtendimento. ProdutoAtendimento have some properties and 2 of this properties are categoriaProduto and fornecedor. Below we can see the object ProdutoAtendimento:
In component, i just have a dropdown using ProdutoAtendimento object and the properties categoriaProduto and fornecedor:
So, in the new version of primereact, 10.7.0, when i create an instance of categoriaProduto or fornecedor with the description equals a empty string like '' i got the error below:
When i chance the properties description to any string value like 'test', the component works fine.
Thats the problem, '' is a valid string to init my component and its works fine in 10.6.6 versions and all versions.
So, to fix my application i need to go to categoriaProduto and fornecedor objects and change de instance method to use a fake value in descricao properties to my app works.
export interface ICategoriaProduto {
id: number
descricao: string
status: boolean
}
export const initCategoriaProduto = (): ICategoriaProduto => ({
id: 0,
descricao: 'test', //i put this fake value here and "fix" the problem
status: false
})
export interface IFornecedor {
id: number
descricao: string
status: boolean
}
export const initFornecedor = (): IFornecedor => ({
id: 0,
descricao: 'test', //i put this fake value here and "fix" the problem
status: true
})
Even though my paleative solution works, it still seems like a bug in the Dropdown component.
and it always worked in previous versions
Reproducer
No response
PrimeReact version
10.7.0
React version
18.x
Language
TypeScript
Build / Runtime
Next.js
Browser(s)
No response
Steps to reproduce the behavior
When you use a default value to an object with de description propertie with the default value equals an empty string like "", the dropdown component don't work. and it always worked in previous versions.
i put a fake value to "fix" my problem:
{
id: 0,
descricao: 'test', // fake value here to fix my problem
status: true
}
Expected behavior
The dropdown component needs to work, with a default value like the object below:
{
id: 0,
descricao: '',
status: true
}
The text was updated successfully, but these errors were encountered: