-
Notifications
You must be signed in to change notification settings - Fork 922
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
TypeError: Cannot set property 'svg4everybody' of undefined #3909
Comments
Getting the same error on upgrade to 2.10 in a Gatsby-React application. |
Seeing this same issue in Vue. |
Fix is on the way |
In JavaScript almost everything is an object, null and undefined are exception. if a variable has been declared, but has not been assigned a value, is automatically assigned the value undefined . Therefore, if you try to access the value of such variable, it will throw Uncaught TypeError cannot set property '0' of undefined/null . JavaScript null and undefined is one of the main reasons to produce a runtime errors . This happens because you don't check the value of unknown return variables before using it. If you are not sure a variable that will always have some value, the best practice is to check the value of variables for null or undefined before using them. The standard way to catch null and undefined simultaneously is this:
Because null == undefined is true, the above code will catch both null and undefined. Also you can write equivalent to more explicit but less concise:
This should work for any variable that is either undeclared or declared and explicitly set to null or undefined. |
Describe the bug
Upgrading to uswds@2.10.0 causes the following error in a Typescript React application:
Steps to reproduce the bug
In a standard create-react-app:
System setup
Additional context
Our application was working without a problem with the previous version uswds@2.9.0.
Our package.json can be found here: https://github.com/awslabs/performance-dashboard-on-aws/blob/mainline/frontend/package.json.
The text was updated successfully, but these errors were encountered: