Repository: apache/airflow
File: providers/edge3/src/airflow/providers/edge3/plugins/www/src/components/ui/toaster.tsx (TypeScript)

Code before:
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
import { Toaster as ChakraToaster, Portal, Spinner, Stack, Toast, createToaster } from "@chakra-ui/react";
import { useRef } from "react";

export const toaster = createToaster({
  pauseOnPageIdle: true,
  placement: "bottom-end",
});

export const Toaster = () => {
  const portalContainerRef = useRef<HTMLDivElement>(null);
  <div ref={portalContainerRef}>{APP}</div>  // <-- FAIL where to import APP from?!?
  return (
    <Portal containerRef={portalContainerRef}>
      {/*   ^^^Error: Type '{ children: Element; containerRef: RefObject<HTMLDivElement | null>; }' is not assignable to type
                      'IntrinsicAttributes & PortalProps & { children?: ReactNode; }'.
                      Property 'containerRef' does not exist on type 'IntrinsicAttributes & PortalProps & { children?: ReactNode; }'.
                      Did you mean 'container'?ts(2322) 
      */}
      <ChakraToaster toaster={toaster} insetInline={{ mdDown: "4" }}>
        {(toast) => (
          <Toast.Root width={{ md: "sm" }}>
            {toast.type === "loading" ? <Spinner size="sm" color="blue.solid" /> : <Toast.Indicator />}
            <Stack gap="1" flex="1" maxWidth="100%">
              {toast.title && <Toast.Title>{toast.title}</Toast.Title>}
              {toast.description && <Toast.Description>{toast.description}</Toast.Description>}
            </Stack>
            {toast.action && <Toast.ActionTrigger>{toast.action.label}</Toast.ActionTrigger>}
            {toast.closable && <Toast.CloseTrigger />}
          </Toast.Root>
        )}
      </ChakraToaster>
    </Portal>
  );
};


Review comment (suggestion):
@bbovenzi / @pierrejeambrun attempted to add as advised but in comments the error that is thrown at me noob.

Code after:
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
import { Toaster as ChakraToaster, Portal, Spinner, Stack, Toast, createToaster } from "@chakra-ui/react";
import type { RefObject } from "react";

export const toaster = createToaster({
  pauseOnPageIdle: true,
  placement: "bottom-end",
});

export const Toaster = ({ containerRef }: { containerRef: RefObject<HTMLDivElement | null> }) => (
  <Portal container={containerRef}>
    <ChakraToaster toaster={toaster} insetInline={{ mdDown: "4" }}>
      {(toast) => (
        <Toast.Root width={{ md: "sm" }}>
          {toast.type === "loading" ? <Spinner size="sm" color="blue.solid" /> : <Toast.Indicator />}
          <Stack gap="1" flex="1" maxWidth="100%">
            {toast.title && <Toast.Title>{toast.title}</Toast.Title>}
            {toast.description && <Toast.Description>{toast.description}</Toast.Description>}
          </Stack>
          {toast.action && <Toast.ActionTrigger>{toast.action.label}</Toast.ActionTrigger>}
          {toast.closable && <Toast.CloseTrigger />}
        </Toast.Root>
      )}
    </ChakraToaster>
  </Portal>
);