So my question is why does this work and displays dots :
<Field label="Password" value="•••••" type="password" />
And the above just displays the plain hexa code !
<Field label="Password" value={`${'•'.repeat(10)}`} type="password" />
My Field component :
function renderValueByType(value: string, type: string) {
switch (type) {
case 'phone':
return phoneFormatter(value);
default:
return value;
}
}
/**
*
* @param {*} param0
*/
const Field = ({ label, value, type, className }: PropTypes) => (
<div className={className}>
<span className="Field__label">{label}</span>
<span className="Field__content">{renderValueByType(value, type)}</span>
</div>
);
If you set a static string as a prop it will be rendered as is.
If you set a variable as a prop it will be sanitized.
Your best bet here is convert your hex char code to string before passing it down to your component (using String.fromCharCode()
):
<Field
label="Password"
value={String.fromCharCode("0x2022").repeat(10)}
type="password"
/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With