mirror of
https://github.com/outline/outline.git
synced 2026-12-01 09:22:14 +03:00
fix: Update DocumentMetaWithViews to hooks, correctly observe store changes
closes #1555
This commit is contained in:
1 parent
85f7e03921
commit
e67d319e2b
1 file changed
+6
-6
@@ -1,20 +1,20 @@
|
||||
// @flow
|
||||
import { inject } from "mobx-react";
|
||||
import { useObserver } from "mobx-react";
|
||||
import * as React from "react";
|
||||
import styled from "styled-components";
|
||||
import ViewsStore from "stores/ViewsStore";
|
||||
import Document from "models/Document";
|
||||
import DocumentMeta from "components/DocumentMeta";
|
||||
import useStores from "../hooks/useStores";
|
||||
|
||||
type Props = {|
|
||||
views: ViewsStore,
|
||||
document: Document,
|
||||
isDraft: boolean,
|
||||
to?: string,
|
||||
|};
|
||||
|
||||
function DocumentMetaWithViews({ views, to, isDraft, document }: Props) {
|
||||
const totalViews = views.countForDocument(document.id);
|
||||
function DocumentMetaWithViews({ to, isDraft, document }: Props) {
|
||||
const { views } = useStores();
|
||||
const totalViews = useObserver(() => views.countForDocument(document.id));
|
||||
|
||||
return (
|
||||
<Meta document={document} to={to}>
|
||||
@@ -45,4 +45,4 @@ const Meta = styled(DocumentMeta)`
|
||||
}
|
||||
`;
|
||||
|
||||
export default inject("views")(DocumentMetaWithViews);
|
||||
export default DocumentMetaWithViews;
|
||||
Reference in new issue
Block a user