Skip to content

Instantly share code, notes, and snippets.

@kisildev
Created January 30, 2020 23:35
Show Gist options
  • Save kisildev/1e56e4557781149ba458c4baed4084dc to your computer and use it in GitHub Desktop.
Save kisildev/1e56e4557781149ba458c4baed4084dc to your computer and use it in GitHub Desktop.
Divide name with symbol
export default (fullName: string) => (
fullName.split(' ').map((item, index) => {
return index === 1 ? `@${item}` : item;
})
)
import React from 'react';
import { divideName } from '../../utils';
interface UserNameProps {
fullName: string;
}
const UserName = (props: UserNameProps) => {
const dividedName = divideName(props.fullName);
return (
<>
{dividedName.map((name: string) => (
<span key={name} className="user_name">
{name}
&nbsp;
</span>
))}
</>
);
}
export default UserName;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment