From 464e020b2dc7020ec77e0391d076b0603dbaa526 Mon Sep 17 00:00:00 2001 From: zyhou Date: Fri, 24 May 2019 10:21:22 +0200 Subject: [PATCH] fix bug uselector ? Lets see --- examples/simple/src/comments/PostQuickCreate.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/examples/simple/src/comments/PostQuickCreate.js b/examples/simple/src/comments/PostQuickCreate.js index acd65cf4e08..77158a65491 100644 --- a/examples/simple/src/comments/PostQuickCreate.js +++ b/examples/simple/src/comments/PostQuickCreate.js @@ -1,6 +1,6 @@ import React, { useCallback } from 'react'; import PropTypes from 'prop-types'; -import { useSelector, useDispatch } from 'react-redux'; +import { connect, useSelector, useDispatch } from 'react-redux'; import { makeStyles } from '@material-ui/styles'; import { CREATE, @@ -33,10 +33,9 @@ const useStyles = makeStyles({ form: { padding: 0 }, }); -const PostQuickCreate = ({ onCancel, onSave }) => { +const PostQuickCreateView = ({ submitting, onCancel, onSave }) => { const classes = useStyles(); const dispatch = useDispatch(); - const submitting = useSelector(state => state.admin.loading > 0); const handleSave = useCallback( values => { @@ -81,9 +80,13 @@ const PostQuickCreate = ({ onCancel, onSave }) => { ); }; -PostQuickCreate.propTypes = { +PostQuickCreateView.propTypes = { onCancel: PropTypes.func.isRequired, onSave: PropTypes.func.isRequired, }; -export default PostQuickCreate; +const mapStateToProps = state => ({ + submitting: state.admin.loading > 0, +}); + +export default connect(mapStateToProps)(PostQuickCreateView);