Skip to content

Commit

Permalink
docs: Embedding in existing react App (#1626)
Browse files Browse the repository at this point in the history
Added how to embed OHIF viewer in an existing React application
  • Loading branch information
nisalup authored Apr 10, 2020
1 parent d769e5c commit 2412c08
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions docs/latest/deployment/recipes/embedded-viewer.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,39 @@ globally defined styles/scripts.
> We're trying to embed the OHIF Viewer into an existing React App, but seeing
> react-dom and react conflicts. What can we do?
If you are installing OHIF viewer inside another react app, you may use `installViewer` as follows:
```
import { installViewer } from '@ohif/viewer'
const ohifViewerConfig = window.config // or set it here
const containerId = 'ohif'
const componentRenderedOrUpdatedCallback = function() {
console.log('OHIF Viewer rendered/updated');
};
componentDidMount() {
installViewer(
ohifViewerConfig,
containerId,
componentRenderedOrUpdatedCallback
);
}
render () {
...
//you can render in any element you wish
<AnyTag id={containerId}/>
}
```

`installViewer` is a convenience method that pulls in some dependencies that may
not be compatible with existing `react` apps. `@ohif/viewer` also exports `App`
which is a react component that takes the `configuration` outlined above as
props. You can use it as a reusable component, and to avoid `react` version
conflict issues.


<!--
LINKS
-->
Expand Down

0 comments on commit 2412c08

Please sign in to comment.