Sha256: e28041e36b7ced9cc0114527c4ec7a369dfaf13ed35f260ff28b9595815d9074
Contents?: true
Size: 797 Bytes
Versions: 1
Compression:
Stored size: 797 Bytes
Contents
import React, { useEffect, useState } from "react"; import PropTypes from "prop-types"; import store from "stores/main"; import { commentsForArticle } from "selectors/comments"; import CommentModel from "models/article/Comment"; function CommentsNumber(props) { const [comments, setComments] = useState(props.comments); useEffect(() => { const unsubscribe = store.subscribe(() => { setComments(commentsForArticle(store.getState(), props.articleId)); }); return () => { unsubscribe(); }; }); return <>{`${comments.length} comment${comments.length === 1 ? "" : "s"}`}</>; } CommentsNumber.propTypes = { articleId: PropTypes.number.isRequired, comments: PropTypes.arrayOf(PropTypes.instanceOf(CommentModel)).isRequired }; export default CommentsNumber;
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
loco-rails-3.0.4 | test/dummy/frontend/js/containers/main/articles/CommentsNumber.js |