Skip to content

Instantly share code, notes, and snippets.

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 (
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--
@t0kio2
t0kio2 / getDayOfWeek.js
Created December 29, 2024 02:23
getDayOfWeek
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]
}