Update docs (nextjs, next.config.js) #884
Open
+3
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
I've made a small contribution aimed at addressing an issue noted in #860. The problem was concerning the possibility of a TypeError occurring in the next.config.js example code provided in the svgr documentation.
In the original example code:
If rule.test is not an instance of RegExp but some other type that does not have the .test method, a TypeError occurs as such:
To prevent this error, I've introduced a type check to see if rule.test is an instance of RegExp, thus making the code more robust and error-proof.
Here's the updated code snippet:
With this modification, the aforementioned TypeError can be effectively prevented, increasing the reliability and usability of the example code. This change contributes to the resolution of issue #860.
Test plan
To demonstrate the solidity of the code changes, the following steps will be executed:
Install Next.js version 13 or higher.
Follow the instructions provided in the documentation to set up and configure the next.config.js file.
Set up SVGR according to the documentation.
Run the application.