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

Empty array crashes Messages component #928

Closed
partynikko opened this issue Jun 19, 2019 · 1 comment
Closed

Empty array crashes Messages component #928

partynikko opened this issue Jun 19, 2019 · 1 comment
Assignees
Labels
Type: Bug Issue contains a defect related to a specific component.
Milestone

Comments

@partynikko
Copy link
Contributor

partynikko commented Jun 19, 2019

I'm submitting a ... (check one with "x")

[x] bug report
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://forum.primefaces.org/viewforum.php?f=57

Codesandbox Case (Bug Reports)
https://codesandbox.io/s/primereact-test-k2ut6

Current behavior
If an empty array [] is supplied to the show method of the <Messages /> component it will crash.

I have found the issue and the solution as well. The reason it is crashing is because newMessages within the show method is not assigned (only declared) which makes the value undefined. When the component then later tries to iterate this.state.messages its undefined which is why its crashing. Simply declaring it like this will solve the issue: let newMessages = [];

I will submit a PR for this.

Expected behavior
I expect it not to crash but instead not show any messages.

Minimal reproduction of the problem with instructions
https://codesandbox.io/s/primereact-test-k2ut6

  • PrimeReact version:
    v3.0.0
  • Browser:
    all

  • Language:
    all

partynikko added a commit to partynikko/primereact that referenced this issue Jun 19, 2019
@mertsincan mertsincan self-assigned this Jun 20, 2019
@mertsincan mertsincan added the Type: Bug Issue contains a defect related to a specific component. label Jun 20, 2019
@mertsincan mertsincan added this to the 3.1.5 milestone Jun 20, 2019
@mertsincan
Copy link
Member

Thanks a lot for the PR ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a defect related to a specific component.
Projects
None yet
Development

No branches or pull requests

2 participants