Created
January 30, 2020 23:35
-
-
Save kisildev/1e56e4557781149ba458c4baed4084dc to your computer and use it in GitHub Desktop.
Divide name with symbol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default (fullName: string) => ( | |
fullName.split(' ').map((item, index) => { | |
return index === 1 ? `@${item}` : item; | |
}) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} | |
| |
</span> | |
))} | |
</> | |
); | |
} | |
export default UserName; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment