Below is my source code
EDTIComp.tsx
function SentenceBuild(props: {
form: FormHook
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 (
{showStartsOn && (
prefix='starting on' readOnly={props.readOnly} value={moment(startsOn).format(ValidDateFormats.Edit)} default='[date]' /> )}
);
}
EDSF.tsx
const performedOnMoment = Here I want to showStartsOn value
amar PraveenPosted Jan 2, 2025, 12:23 PM
Same steps I have followes but no luck.
Can you please let us know if anything need to change
amar PraveenPosted Dec 29, 2024, 11:04 AM
Naimish MakwanaPosted Dec 28, 2024, 12:44 PM
To pass the
showStartsOnvalue from theSentenceBuildcomponent to the parent component (EDSF.tsx), you can use a callback function. Here's how you can modify your code:EDSF.tsx) to receive theshowStartsOnvalue.SentenceBuildcomponent.SentenceBuildcomponent to pass theshowStartsOnvalue.Here's an example:
EDSF.tsx EDTIComp.tsxIn this example:
EDSFcomponent defines a state variableperformedOnMomentand a callback functionhandleShowStartsOn.SentenceBuildcomponent receives the callback function as a prop (onShowStartsOnChange) and invokes it with theshowStartsOnvalue.This way, the
showStartsOnvalue is passed from the child component (SentenceBuild) to the parent component (EDSF).Thanks