microsoft / reactxp

Library for cross-platform app development.
https://microsoft.github.io/reactxp/
Other
8.29k stars 493 forks source link

React Legacy ContextTypes API Deprecation / Migration #1128

Open fbartho opened 5 years ago

fbartho commented 5 years ago

Filing a new ticket to track that we need to migrate ReactXP off of the legacy Context APIs and onto a more modern one!

@mikehardy shared the following:

(virtualenv) mike@kunashir:~/work/react-random/reactxp (unsafe-react-names) % grep -ri contexttypes *|grep -v dist | grep -v node_modules
src/web/Link.tsx:    static contextTypes = {
src/web/GestureView.tsx:    static contextTypes: React.ValidationMap<any> = {
src/web/TextInput.tsx:    static contextTypes: React.ValidationMap<any> = {
src/web/RootView.tsx:    static childContextTypes: React.ValidationMap<any> = {
src/web/RootView.tsx:    static childContextTypes: React.ValidationMap<any> = {
src/web/View.tsx:    static contextTypes: React.ValidationMap<any> = {
src/web/View.tsx:    static childContextTypes: React.ValidationMap<any> = {
src/web/Button.tsx:    static contextTypes = {
src/web/Button.tsx:    static childContextTypes = {
src/web/Image.tsx:    static contextTypes: React.ValidationMap<any> = {
src/web/Image.tsx:    static childContextTypes: React.ValidationMap<any> = {
src/web/Text.tsx:    static contextTypes = {
src/web/Text.tsx:    static childContextTypes: React.ValidationMap<any> = {
src/native-desktop/RootView.tsx:        static childContextTypes: React.ValidationMap<any> = {
src/native-common/Link.tsx:    static contextTypes = {
src/native-common/TextInput.tsx:    static contextTypes: React.ValidationMap<any> = {
src/native-common/View.tsx:    static contextTypes: React.ValidationMap<any> = {
src/native-common/View.tsx:    static childContextTypes: React.ValidationMap<any> = {
src/native-common/Button.tsx:    static contextTypes = {
src/native-common/Button.tsx:    static childContextTypes: React.ValidationMap<any> = {
src/native-common/Image.tsx:    static childContextTypes: React.ValidationMap<any> = {
src/native-common/Text.tsx:    static contextTypes: React.ValidationMap<any> = {
src/native-common/Text.tsx:    static childContextTypes: React.ValidationMap<any> = {
src/common/PopupContainerViewBase.tsx:    static contextTypes: React.ValidationMap<any> = {
src/common/PopupContainerViewBase.tsx:    static childContextTypes: React.ValidationMap<any> = {
src/common/utils/FocusManager.ts:    const contextTypes = Component.contextTypes || {};
src/common/utils/FocusManager.ts:    contextTypes.focusManager = PropTypes.object;
src/common/utils/FocusManager.ts:    Component.contextTypes = contextTypes;
src/windows/View.tsx:    static contextTypes: React.ValidationMap<any> = {
src/windows/View.tsx:        ...ViewCommon.contextTypes
src/windows/View.tsx:    static childContextTypes: React.ValidationMap<any> = {
src/windows/View.tsx:        ...ViewCommon.childContextTypes
src/windows/Button.tsx:    static childContextTypes: React.ValidationMap<any> = {
src/windows/Button.tsx:        ...ButtonBase.childContextTypes
src/windows/Text.tsx:    static contextTypes: React.ValidationMap<any> = {
src/windows/Text.tsx:        ...TextBase.contextTypes
src/windows/Text.tsx:    static childContextTypes: React.ValidationMap<any> = {
src/windows/Text.tsx:        ...TextBase.childContextTypes
(virtualenv) mike@kunashir:~/work/react-random/reactxp (unsafe-react-names) % grep -ri getchildcontext *|grep -v dist | grep -v node_modules
src/web/RootView.tsx:    getChildContext(): MainViewContext {
src/web/RootView.tsx:    getChildContext() {
src/web/View.tsx:    getChildContext() {
src/web/Button.tsx:    getChildContext(): ButtonContext {
src/web/Image.tsx:    getChildContext() {
src/web/Text.tsx:    getChildContext() {
src/native-desktop/RootView.tsx:        getChildContext() {
src/native-common/View.tsx:    getChildContext() {
src/native-common/Button.tsx:    getChildContext(): ButtonContext {
src/native-common/Image.tsx:    getChildContext() {
src/native-common/Text.tsx:    getChildContext() {
src/common/PopupContainerViewBase.tsx:    getChildContext() {
src/windows/View.tsx:    getChildContext() {
src/windows/View.tsx:        const childContext: ViewContext = super.getChildContext();
src/windows/Button.tsx:    getChildContext(): ButtonContext {
src/windows/Button.tsx:        const childContext: ButtonContext = super.getChildContext();
src/windows/Text.tsx:    getChildContext(): TextContext {
src/windows/Text.tsx:        const childContext: TextContext = super.getChildContext();

Related Ticket: #1039 Related Twitter Thread: @dan_abramov -- Performance Implications! Documentation: https://reactjs.org/docs/context.html

This is a breaking change that depends on React >= 16.3.

fbartho commented 4 years ago

@erictraut -- this is still an active concern. -- Do we have a roadmap to when we might be able to declare that reactxp is only compatible with React >=16.3? -- I'm happy to provide the PR if now is a good time.

erictraut commented 4 years ago

In the past, we've said that we will generally support older versions of RN and React for one year after they have been replaced by newer versions. Can you remind me when React 16.3 was released? If it's more than a year ago, then I think we can go ahead and deprecate support in reactxp for older versions.

fbartho commented 4 years ago

@erictraut https://reactjs.org/blog/2018/03/29/react-v-16-3.html -- March of 2018!

erictraut commented 4 years ago

Great, then we can move forward with this deprecation now.