amar Praveen

amar Praveen

  • 1.4k
  • 13
  • 641

Passing Date Picker Value from Child to Parent (Callback Function)

Dec 27 2024 10:57 AM

Below is my source code

EDTIComp.tsx

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>

    );

}

EDSF.tsx

 const performedOnMoment = Here I want to showStartsOn value

 

 

  •  
  •  
  •