forked from mahipalsingh7/react-native-material-textfield
-
Notifications
You must be signed in to change notification settings - Fork 10
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
Various tweaks for compatibility with react-native-web #3
Open
DaleWebb
wants to merge
3
commits into
TheLartians:master
Choose a base branch
from
DaleWebb:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just return
this.props
at this point? Also unsure if this could trigger warnings / unexpected behaviour if arbitrary props get forwarded to theTextInput
component below.How about adding a whitelist with the supported
TextInput
props and using it to filter the props?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, both good points!
I opted to retain the loop to indicate where an escape clause for a prop could be easily added in the future, if the previously existing escape clause needed to be added again (e.g.
"defaultValue" === key
).True - an oversight on my part as I'm a TypeScript user and rely on TS to warn of invalid props.
I thought about this and I wasn't sure if the chance of an error in missing out a supported prop (either by mistake or because
react-native
adds one in the future) was worth the reward. Also, conscious of React Native not supporting prop types any more.Happy for suggestions on what you think the best approach for this would be if you can think of an alternative to supporting a copied array of supported props.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I'm a TypeScript user myself, so I'm also all in favour of removing the
propTypes
overhead. The issue however is that the outer component accepts more props than a standardTextInput
. Therefore, TypeScript should also accept these additional parameters without emitting a warning either.The original uses
TextInput.propTypes
as a whitelist to filter out theTextInput
props out from the fullTextField
props, so that nothing unexpected ends up there. Perhaps a blacklist would be better suited in the future - we already know which props are meant for the outerTextField
component (e.g. by checking thepropTypes
defined above), so removing them should leave us with the props meant for theTextInput
.