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

fix: handle properly null and undefined props values #41

Merged

Conversation

marcuspoehls
Copy link
Contributor

πŸ”— Linked issue

I didn’t create an issue and instead provide a failing test.

❓ Type of change

  • πŸ“ Test to reproduce an issue
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

I’m running into Cannot read properties of undefined (reading 'Symbol(ignoreFirstLoad)') if a response prop is null or undefined. We allow props having string | undefined values and currently this fails because the code always assumes a value.

I provided a failing test to reproduce the issue.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@marcuspoehls
Copy link
Contributor Author

The issue is in src/inertia.ts https://github.com/adonisjs/inertia/blob/ee11d9bcfd9a90c0c845bae278f92856ee351a71/src/inertia.ts#L106C56-L106C66.

@Julien-R44 Julien, I’m not sure how you like to handle null and undefined props. The value in the linked line should handle nullish props. You may add a check as you’re more into the code. Otherwise I could edit the mentioned line and add checks.

@Julien-R44
Copy link
Member

Thanks for the failing test !

Yeah, I think that props should be returned even if they are null or undefined

@Julien-R44 Julien-R44 changed the title Fix Cannot read properties of undefined (reading 'Symbol(ignoreFirstLoad)') fix: handle properly null and undefined props values Oct 15, 2024
@Julien-R44 Julien-R44 merged commit e3372ac into adonisjs:2.x Oct 15, 2024
5 checks passed
@marcuspoehls
Copy link
Contributor Author

@Julien-R44 thank you for taking this pull request over making the adjustments. And also thank you for a new release 🫢

@marcuspoehls
Copy link
Contributor Author

@Julien-R44 I can confirm that our app works as expected again with nullish props in @adonisjs/inertia:2.x πŸ™‚ thank you!

@marcuspoehls marcuspoehls deleted the fix-cannot-read-symbol-ignoreFirstLoad branch October 16, 2024 06:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants