* chore: configure WDYR for react profiling * perf: reduced post content re-rendering * perf: post content view and it child optimization * perf: add memoization in post editor * perf: add memoization in postCommnetsView * perf: improved endorsed comment view rendering * perf: improved re-rendering in reply component * fix: uncomment questionType commentsView * fix: removed console errors in postContent area * perf: reduced postType and postId dependancy * perf: improved re-rendering in discussionHome * perf: improved re-rendering of postsList and its child components * perf: improved re-rendering of legacyTopic and learner sidebar * fix: postFilterBar filter was not updating * fix: resolve duplicate comment posts issue * fix: memory leaking issue in comments view * fix: duplicate topic posts in inContext sidebar * perf: add lazy loading * chore: remove WDYR configuration * fix: alert banner padding * chore: update package-lock file * fix: bind tour API call with buttons
31 lines
816 B
JavaScript
31 lines
816 B
JavaScript
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { getIn, useFormikContext } from 'formik';
|
|
|
|
import { Form, TransitionReplace } from '@edx/paragon';
|
|
|
|
const FormikErrorFeedback = ({ name }) => {
|
|
const { touched, errors } = useFormikContext();
|
|
const fieldTouched = getIn(touched, name);
|
|
const fieldError = getIn(errors, name);
|
|
|
|
return (
|
|
<TransitionReplace>
|
|
{fieldTouched && fieldError ? (
|
|
<Form.Control.Feedback type="invalid" hasIcon={false} key={`${name}-error-feedback`}>
|
|
{fieldError}
|
|
</Form.Control.Feedback>
|
|
) : (
|
|
<React.Fragment key={`${name}-no-error-feedback`} />
|
|
)}
|
|
</TransitionReplace>
|
|
);
|
|
};
|
|
|
|
FormikErrorFeedback.propTypes = {
|
|
name: PropTypes.string.isRequired,
|
|
};
|
|
|
|
export default React.memo(FormikErrorFeedback);
|