Repository navigation
Conversation
There was a problem hiding this comment.
Curious about thoughts on this. Is it left over from an old RN version? Not sure if it is safe to remove.
There was a problem hiding this comment.
There are no internal callsites of this. The only other thing that defines getInnerViewNode is ScrollView and innerViewRef is never ScrollView. Let's kill it.
RSNara
left a comment
There was a problem hiding this comment.
🤔This refactor is incomplete.
Did you consider doing 👇 to implement the NativeMethodsMixin methods?
class DrawerLayoutAndroid extends React.Component<Props, State> {
// ...
blur(): void {
return this.nativeRef.blur();
}
focus(): void {
return this.nativeRef.focus();
}
measure(callback: MeasureOnSuccessCallback): void {
return this.nativeRef.measure(callback);
}
measureInWindow(callback: MeasureInWindowOnSuccessCallback): void {
return this.nativeRef.measureInWindow(callback);
}
measureLayout(
relativeToNativeNode: number,
onSuccess: MeasureLayoutOnSuccessCallback,
onFail: () => void,
): void {
return this.nativeRef.measureLayout(
relativeToNativeNode,
onSuccess,
onFail,
);
}
setNativeProps(nativeProps: Object): void {
return this.nativeRef.setNativeProps(nativeProps);
}
// ...
}|
My thoughts on why I did it that way: That would make the wrapper more complex, and would have to be changed whenever This is the approach Can, of course, update this if this is not a good option however! 👍 |
|
It seems like this is a problem with needing to add additional methods to the public API of the component when using As an additional data point, of the 8 or so callsites of this component inside of Facebook, they only use If we want to keep the API the same, I think I would bias towards what @RSNara proposed so that we can hide the implementation details. Otherwise maybe we should just drop support for the native methods? |
8fe2ac6 to
2d97b41
Compare
|
Implemented the native methods. Could also serve as some boilerplate for if this needs to be done on other classes in the future, too. How do you feel about this implementation? Also looks like CI is failing because circleci is not yet able to see the latest metro version on npm |
|
Thanks for iterating on this, @empyrical! |
facebook-github-bot
left a comment
There was a problem hiding this comment.
@RSNara has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
|
@empyrical merged commit bea3bb6 into |
Summary: This pull requests converts `DrawerLayoutAndroid` from a `createReactClass`-based component to an ES6 class component, removing its use of `NativeMethodsMixin` and `prop-types` in the process. Unfortunately this couldn't be moved over to a full `forwardRef` to the native component, because it has the methods `openDrawer` and `closeDrawer` as part of its API, and they can't be called directly on the native component. A `createRef`-based ref to the native component can be accessed from the `nativeRef` property of a `DrawerLayoutAndroid` instance if a native ref is needed. The Flow types for callbacks have also been filled out. Pull Request resolved: react#21980 Reviewed By: TheSavior Differential Revision: D12901951 Pulled By: RSNara fbshipit-source-id: d35fa5f11b1059f49b466b52abeec902db1d22f7
This pull requests converts
DrawerLayoutAndroidfrom acreateReactClass-based component to an ES6 class component, removing its use ofNativeMethodsMixinandprop-typesin the process.Unfortunately this couldn't be moved over to a full
forwardRefto the native component, because it has the methodsopenDrawerandcloseDraweras part of its API, and they can't be called directly on the native component. AcreateRef-based ref to the native component can be accessed from thenativeRefproperty of aDrawerLayoutAndroidinstance if a native ref is needed.The Flow types for callbacks have also been filled out.
Test Plan:
yarn flow-check-androidpasses. I've tried it out in the Android simulator, and no regressions have been noted.Release Notes:
[GENERAL] [ENHANCEMENT] [Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js] - Converted to class component