React-native: Migrate off of old context APIs

Created on 18 Feb 2020  路  17Comments  路  Source: facebook/react-native

We want to get rid of our usage of the prop-types package. The last remaining usage of this is a couple of old components that use the old React context API. We need to migrate these components to use the modern React.createContext API.

The components using the old context API are:

For more information about the old API and how to migrate to the new API you can check out the React docs for Context: https://reactjs.org/docs/context.html#classcontexttype

If we are able to remove the usage of prop-types from React Native we should be able to substantially lower the bundle size of React Native. We'd love your help!

JavaScript

Most helpful comment

I'd love to help out! Could I work on Modal?

All 17 comments

I'd love to help out! Could I work on Modal?

I would love to take care of Incremental :)

hey there, I can check virtualizedlist

@Naturalclar @mikaoelitiana they're all yours to take :)

@thymikee thanks, I am already working on VirtualizedList, the module is quite big and I try to make sure I am doing things the right way

It looks like Modal actually only uses the VirtualizedList Context and AppContainer Context, it doesn't have its own context. So we need to get the VirtualizedList and AppContainer ones done first.

So this means these contexts need to be exported, right?

Yeah, the root tag context is already exported, unstable_RootTagContext, the VirtualizedList one can be exported as a static property on VirtualizedList: VirtualizedList.Context

@TheSavior is the VirtualizedList context used internally at FB? It looks like Modal overwrites the virtualizedList context with null, so it doesn't propagate further and there are no consumers of this inside RN codebase. So, if there are no internal FB components using this context, we could maybe kill it entirely? But I guess there are 馃槃

Yeah, these contexts are all used fairly heavily. Any kind of portal type thing would use it like Modal or BottomSheet.

It appears all of the tasks on this issue have been claimed? Looking for my first RN issue to help out on :)

It appears all of the tasks on this issue have been claimed? Looking for my first RN issue to help out on :)

It appears so. I wanted to work on this but i'll have to move on to another issue

VirtualizedList was migrated in https://github.com/facebook/react-native/commit/7bd694fc6f4bb027b6d7ee04034cad41a43e5695. So only AppContainer left now

Is AppContainer still taken? Or could I give it a try?

can i give appContainer a try too?

If no one is working on AppContainer, then I'd like to take it up. Thanks!

do you can give me simple task to contribute it

Was this page helpful?
0 / 5 - 0 ratings