Skip to content

Internal context default values should support forwards compat with global-context #23624

Description

@ling1726

Global context introduced in #23324 #23367 help with resolving to one single context instance. However, this does not guarantee the forwards compatibility of default values in particular for nested objects and functions

// v1
React.createContext({
  foo: 'string',
})

// v1.1
React.createContext({
  // depends on usage but should be 'fine'
  foo: 'string',
  bar: 1,
  // ⚠️ The below default properties will explode if they are used with v1 context
  baz: () => null,
  kevin: { current: null }
});

There is no guarantee that the the most recent version of the context is used. Therefore, default context values need to be forwards compatible. In particular this affects nested objects and default functions in context. These situations might not happen very often but will crash an app if they are used because of trying to access or call undefined.

This task includes two different sides

Metadata

Metadata

Assignees

Labels

Resolution: Soft CloseSoft closing inactive issues over a certain period

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions