React Hookers - v6.3.0
    Preparing search index...

    Function createDelegatedPropsContext

    • Creates a context that merges delegated props.

      If a provider is nested inside another provider of the same delegate context, it merges its props with the props from the enclosing provider.

      Type Parameters

      • P

        Delegated props.

      Parameters

      • defaultProps: P

        The default props.

      Returns DelegatedPropsContext<P>

      A context that carries delegated props.

      // 1. Create a context
      const MyPropsContext = createDelegatedPropsContext<{ foo: string }>();

      // 2. Use the context in a component
      function Bar() {
      const delegatedProps = useContext(MyPropsContext.context);

      // Use props here
      return delegatedProps?.foo;
      }

      // 3. Render a provider and delegate props to descendants
      <MyPropsContext.Provider value={{ foo: 'hello' }}>
      <Bar />
      </MyPropsContext.Provider>
    • Creates a context that merges delegated props.

      If a provider is nested inside another provider of the same delegate context, it merges its props with the props from the enclosing provider.

      Type Parameters

      • P

        Delegated props.

      Returns DelegatedPropsContext<P | undefined>

      A context that carries delegated props.

      // 1. Create a context
      const MyPropsContext = createDelegatedPropsContext<{ foo: string }>();

      // 2. Use the context in a component
      function Bar() {
      const delegatedProps = useContext(MyPropsContext.context);

      // Use props here
      return delegatedProps?.foo;
      }

      // 3. Render a provider and delegate props to descendants
      <MyPropsContext.Provider value={{ foo: 'hello' }}>
      <Bar />
      </MyPropsContext.Provider>