Last active
February 10, 2021 17:22
-
-
Save ljmotta/71666f46e217ceba0c19e8dfa4eea23a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function useEmbeddedRef() { | |
const [embedded, setEmbedded] = useState<EmbeddedRef | undefined>(null); | |
const embeddedRef = useCallback((node: EmbeddedRef) => { | |
if (node !== null) { | |
setEmbedded(node); | |
} | |
}, []); | |
return { embedded, embeddedRef }; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// usage | |
const UserTaskInstanceDetailsPage: React.FC<RouteComponentProps<MatchProps> & | |
OUIAProps> = ({ ouiaId, ouiaSafe, ...props }) => { | |
// .... | |
// change the useRef for this, or use the hook | |
const [embedded, setEmbedded] = useState<TaskDetailsApi | undefined>(null); | |
const embeddedRef = useCallback((node: TaskDetailsApi) => { | |
if (node !== null) { | |
setEmbedded(node); | |
} | |
}, []); | |
// access the methods on the `embedded` variable | |
// .... | |
<EmbeddedTaskDetails | |
ref={embeddedRef} | |
targetOrigin={window.location.origin} | |
envelopePath={'/envelope/task-details.html'} | |
task={userTask} | |
/> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment