I have this string "Accept terms and conditions" and by design I need to replace part of that string with span tags, that is, "terms" and "conditions" should be wrapped with span like <span>terms</span> and <span>conditions</span>. To find solution I have found How to add color to a specific part of a string in React using replace? but it does not work as expected. So, I have FormInput component which is used like this:
<FormInput
type="checkbox"
value={formik.values.terms}
name="terms"
onChange={formik.handleChange}
onBlur={formik.handleBlur}
label={`Accept terms and conditions`}
checkbox={true}
>
{formik.touched.terms && formik.errors.terms ? (
<ErrorMessage termsCheckbox={true}>
{formik.errors.terms}
</ErrorMessage>
) : null}
</FormInput>
As you can see I am passing label={Accept terms and conditions} and I need to ensure that the words 'terms' and 'conditions' are in red color