diff options
| author | Sam Wilkins <abdullah_ahmed@brown.edu> | 2019-05-09 20:59:10 -0400 |
|---|---|---|
| committer | Sam Wilkins <abdullah_ahmed@brown.edu> | 2019-05-09 20:59:10 -0400 |
| commit | 47ecf8d30f4aa5e25a659fc7f3c0c1487420150e (patch) | |
| tree | cbae92b4aca6cc8427410cc2ec51b0afff1d8ea2 /src/client/views/DocComponent.tsx | |
| parent | ff5e275d4d9bb17866a432459884274cd870a640 (diff) | |
merge with master, but haven't reconciled internal and external linking
Diffstat (limited to 'src/client/views/DocComponent.tsx')
| -rw-r--r-- | src/client/views/DocComponent.tsx | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/client/views/DocComponent.tsx b/src/client/views/DocComponent.tsx new file mode 100644 index 000000000..d6562492f --- /dev/null +++ b/src/client/views/DocComponent.tsx @@ -0,0 +1,14 @@ +import * as React from 'react'; +import { Doc } from '../../new_fields/Doc'; +import { computed } from 'mobx'; + +export function DocComponent<P extends { Document: Doc }, T>(schemaCtor: (doc: Doc) => T) { + class Component extends React.Component<P> { + //TODO This might be pretty inefficient if doc isn't observed, because computed doesn't cache then + @computed + get Document(): T { + return schemaCtor(this.props.Document); + } + } + return Component; +}
\ No newline at end of file |
