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 { connect } from 'react-redux'; | |
export const withBehavior = Component => connect()( | |
class extends React.Component { | |
func = () => console.log('this is hoc') | |
render() { | |
return ( |
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
const calculateAge = (birthdayStr: string) => { | |
if (!birthdayStr) return | |
const birthday = new Date(birthdayStr) | |
const today = new Date() | |
let age = today.getFullYear() - birthday.getFullYear() | |
const monthDiff = today.getMonth() - birthday.getMonth() | |
// 誕生日が来ていない場合、年齢から1引く | |
if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birthday.getDate())) { | |
age-- |
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
const getDayOfWeek = (dayNumber) => { | |
const dayOfWeek = ['日', '月', '火', '水', '木', '金', '土'] | |
if (dayNumber < 0 || dayNumber > 6) { | |
throw new Error('Invalid day number. Must be between 0 and 6') | |
} | |
return dayOfWeek[dayNumber] | |
} |