Open
Conversation
Import flags asynchronously inside a useEffect hook, and set the Image source if component is mounted, with the help of a useState hook. Remove ./flags import from the top.
Move duplicated code to a new function called getFlag.
Use it to pass your own flags, and made it optional.
Allow using flags from ./flags, ./flags/flat, ./flags/flat/16, etc., or directories that match that structure.
Add a description and a few examples.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Hi, @frostney! How's it going?
I made some changes to your code to avoid bundling/importing all flags when using this component, and import only the required flags, to minimize bundle size.
I know it's been a while since you made this, but I'd be great if this gets released someday.
Basically, these changes allow importing flags beforehand and passing them using the
fromparam. To do that:from. This is not a path, it's an optional object that is intended to contain exported flags/images from the./flagssub-directories, like./flags,./flags/flat,./flags/shiny/16, etc. This doesn't affect previous versions.fromis not present. This might affect previous versions, but I don't think so.Hopefully these changes are understandable and easy to read. I added some examples in the
readmefile, and in the code too (just in case). If you need something else, please tell me. I'll be glad to help.Have a nice day, and thank you releasing this project!