amar Praveen

amar Praveen

  • 1.7k
  • 25
  • 1.7k

Pass on component variable value to another component variable

Dec 27 2024 3:23 AM

Component-1

function SentenceBuild(props: {

    form: FormHook<EditMedicationForm.EditMedicationFormStructure>;

    fieldPath: EditMedicationForm.InstructionFields;

    defaultValue: string;

    useDefaultValue: boolean;

    readOnly?: boolean;

}) {

    const startsOn = moment(instruction.startsOn, ValidDateFormats.NodeDateTimeTimezone);

    let showStartsOn = false;

    if (startsOn && startsOn.isValid()) {

        showStartsOn = moment().endOf('day').isBefore(startsOn, 'day');

    

 

    return (

        <div data-test-id={'sentence-builder'} className={styles.sentenceBuilder}>

            {showStartsOn && (

                <SentenceItem

                    prefix='starting on'

                    readOnly={props.readOnly}

                    value={moment(startsOn).format(ValidDateFormats.Edit)}

                    default='[date]'

                />

            )}

        </div>

    );

}

Compnent-2

 const performedOnMoment = Here I want to showStartsOn value

 


Answers (5)