diff options
author | tschicke-brown <tyler_schicke@brown.edu> | 2019-05-03 20:56:32 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-03 20:56:32 -0400 |
commit | 1ccabe155cb4f23c0aa7e37f91cd4a303008b8c7 (patch) | |
tree | 4b93ac202fe813033b6d07f7202ab217c0da79f8 /src/client/views/DocComponent.tsx | |
parent | 95d89a193b25d19faf6da0af1412480a36fc9ebe (diff) | |
parent | 070787b6be93dca4a43ec7e893ae4ac4b4d80e59 (diff) |
Merge pull request #92 from browngraphicslab/newDocs
New docs
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 |