jsifyContextProp function

ReactContext? jsifyContextProp(
  1. Context? value
)

Returns value converted to its JS context representation for storage in a props map, or null of the value is null.

For use in JS component prop getters where the component expects a JS context, but accepting Dart contexts is more convenient to the consumer reading/writing the props.

Should be used alongside unjsifyContextProp.

Implementation

ReactContext? jsifyContextProp(Context? value) {
  if (value == null) return null;

  // Store the original Dart context so we can retrieve it later in unjsifyContextProp.
  // See _dartContextForJsContext comment for more info.
  _dartContextForJsContext.set(value.jsThis, value);
  return value.jsThis;
}