fix: replace buffer decoding with atob
#2808
Open
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
Fixed #2701
First of all, buffer is a built-in API in Node.js, so it cannot be used in React Native.
However, it seems to be used here.
But if someone has installed the buffer package, it would still be imported successfully even if react-native-svg doesn’t explicitly declare it as a dependency (a so-called “phantom dependency”).
Still, it’s strange that react-native-svg has buffer as a dependency.
Therefore, we should replace it with atob (a built-in API) for the conversion, and remove buffer from the code
If you are using an older version of React Native, atob might not be available in Hermes.
However, since there are already many polyfill implementations for atob, it’s still better than having no buffer at all.
Test Plan
https://github.com/Nodonisko/hermesx
i have test hermesx
mkdir buffer-test cd buffer-test npm init npm install -g hermesx npm install bufferCreate test code
test.tsDemonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes UI.
What's required for testing (prerequisites)?
What are the steps to reproduce (after prerequisites)?
Compatibility
Checklist
README.md__tests__folder