-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Text: Cleanup Native Component Configuration
Summary: Cleans up the native component configuration for `RCTText` and `RCTVirtualText`. This //does// lead to a breaking change because `Text.viewConfig` will no longer exist. However, I think this is acceptable because `viewConfig` has already long stopped being an exported prop on other core components (e.g. `View`). Changelog: [General][Removed] - `Text.viewConfig` is no longer exported. Reviewed By: shergin Differential Revision: D23708205 fbshipit-source-id: 1ad0b0772735834d9162a65d9434a9bbbd142416
- Loading branch information
1 parent
9da4d87
commit 06ce643
Showing
2 changed files
with
81 additions
and
62 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow | ||
* @format | ||
*/ | ||
|
||
'use strict'; | ||
|
||
import ReactNativeViewAttributes from '../Components/View/ReactNativeViewAttributes'; | ||
import UIManager from '../ReactNative/UIManager'; | ||
import {type HostComponent} from '../Renderer/shims/ReactNativeTypes'; | ||
import createReactNativeComponentClass from '../Renderer/shims/createReactNativeComponentClass'; | ||
import {type ProcessedColorValue} from '../StyleSheet/processColor'; | ||
import {type TextProps} from './TextProps'; | ||
|
||
type NativeTextProps = $ReadOnly<{ | ||
...TextProps, | ||
isHighlighted?: ?boolean, | ||
selectionColor?: ?ProcessedColorValue, | ||
}>; | ||
|
||
export const NativeText: HostComponent<NativeTextProps> = (createReactNativeComponentClass( | ||
'RCTText', | ||
() => ({ | ||
validAttributes: { | ||
...ReactNativeViewAttributes.UIView, | ||
isHighlighted: true, | ||
numberOfLines: true, | ||
ellipsizeMode: true, | ||
allowFontScaling: true, | ||
maxFontSizeMultiplier: true, | ||
disabled: true, | ||
selectable: true, | ||
selectionColor: true, | ||
adjustsFontSizeToFit: true, | ||
minimumFontScale: true, | ||
textBreakStrategy: true, | ||
onTextLayout: true, | ||
onInlineViewLayout: true, | ||
dataDetectorType: true, | ||
}, | ||
directEventTypes: { | ||
topTextLayout: { | ||
registrationName: 'onTextLayout', | ||
}, | ||
topInlineViewLayout: { | ||
registrationName: 'onInlineViewLayout', | ||
}, | ||
}, | ||
uiViewClassName: 'RCTText', | ||
}), | ||
): any); | ||
|
||
export const NativeVirtualText: HostComponent<NativeTextProps> = | ||
UIManager.getViewManagerConfig('RCTVirtualText') == null | ||
? NativeText | ||
: (createReactNativeComponentClass('RCTVirtualText', () => ({ | ||
validAttributes: { | ||
...ReactNativeViewAttributes.UIView, | ||
isHighlighted: true, | ||
maxFontSizeMultiplier: true, | ||
}, | ||
uiViewClassName: 'RCTVirtualText', | ||
})): any); |
06ce643
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.
Hey @yungsters, you moved the viewConfig into the
NativeText
component within this commit. I looks that theandroid_hyphenationFrequency
was accidentally dropped while moving the code. This code was added here: https://github.com/facebook/react-native/pull/29157/filesOr is the fix with hyphenation somewhere else? I am using react-native@0.63.4 and facing the hyphenation problem on android.
Or is the code elsewhere and everything is fine? Do you know, if this is to be released with 0.64?
Thanks for your help :)
06ce643
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.
@fmacherey Thanks for pointing that discrepancy out. That was an oversight and definitely needs to be fixed. Would you be interested in sending a PR to fix it? If not, I can get to it later this week.
06ce643
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.
@yungsters Thanks for your reply. I'm not so fluent with the react-native code itself, so if its okay, I would prefer you can do this? Thanks for your help :)
06ce643
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.
I have an internal pull request to bring this back. Once accepted and landed, it will appear in the repository. Thanks again for reporting this!
06ce643
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.
1433ed6 restores
android_hyphenationFrequency
onNativeText
. Thanks again!06ce643
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.
No problem. Thanks for your help 😃 .