Phantom Stories Library - v0.0.8
    Preparing search index...

    Function ValidationRender

    • A component that renders a Validation ADT by matching its state to provided Passing or Failing components.

      Type Parameters

      • T

        The type of the data in Passing state.

      Parameters

      • props: Props<T>

        The component props, including the Validation instance and rendering components.

      Returns ReactNode

      A React node representing the rendered Validation state.

      const MyPassing: React.FC<PassingProps<number>> = ({ value }) => <p>Valid: {value}</p>;
      const MyFailing: React.FC<FailingProps<number>> = ({ messages }) => <p>Errors: {messages.join(', ')}</p>;
      const validation = Validation.Passing(42);
      <ValidationRender validation={validation} Passing={MyPassing} Failing={MyFailing} />