File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
compiler/packages/babel-plugin-react-compiler/src/HIR Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -434,6 +434,25 @@ const EnvironmentConfigSchema = z.object({
434434 * Here the variables `ref` and `myRef` will be typed as Refs.
435435 */
436436 enableTreatRefLikeIdentifiersAsRefs : z . boolean ( ) . nullable ( ) . default ( false ) ,
437+
438+ /*
439+ * If enabled, this lowers any calls to `useContext` hook to use a selector
440+ * function.
441+ *
442+ * The compiler automatically figures out the keys by looking for the immediate
443+ * destructuring of the return value from the useContext call. In the future,
444+ * this can be extended to different kinds of context access like property
445+ * loads and accesses over multiple statements as well.
446+ *
447+ * ```
448+ * // input
449+ * const {foo, bar} = useContext(MyContext);
450+ *
451+ * // output
452+ * const {foo, bar} = useContext(MyContext, (c) => [c.foo, c.bar]);
453+ * ```
454+ */
455+ enableLowerContextAccess : z . boolean ( ) . nullable ( ) . default ( false ) ,
437456} ) ;
438457
439458export type EnvironmentConfig = z . infer < typeof EnvironmentConfigSchema > ;
You can’t perform that action at this time.
0 commit comments