Skip to content

Commit

Permalink
fix: render() arrow function replace to named function
Browse files Browse the repository at this point in the history
  • Loading branch information
mimokmt committed Jan 26, 2024
1 parent e0d83b1 commit b70d0cc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1344,7 +1344,6 @@ exports[`Storyshots Button Nihongo 1`] = `
<button
className="c0 c1"
disabled={false}
onClick={[Function]}
>
日本語だよ
</button>
Expand Down
26 changes: 11 additions & 15 deletions packages/react/src/components/Button/index.story.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { action } from '@storybook/addon-actions'
import { useRef } from 'react'
import { ClickableElement } from '../Clickable'
import Button, { ButtonProps } from '.'
Expand Down Expand Up @@ -75,24 +74,21 @@ export const Link: StoryObj<typeof Button> = {
}

export const Nihongo: StoryObj<typeof Button> = {
render: (args) => (
<Button {...args} onClick={action('click')}>
日本語だよ
render: (args) => <Button {...args}>日本語だよ</Button>,
}

const FocusRender = (args: ButtonProps) => {
const ref = useRef<ClickableElement>(null)
const focus = () => ref.current?.focus()
return (
<Button {...args} onMouseOver={focus} ref={ref}>
Mouse over to focus
</Button>
),
)
}

export const Focus: StoryObj<typeof Button> = {
render: (args: ButtonProps) => {
// eslint-disable-next-line react-hooks/rules-of-hooks
const ref = useRef<ClickableElement>(null)
const focus = () => ref.current?.focus()
return (
<Button {...args} onMouseOver={focus} ref={ref}>
Mouse over to focus
</Button>
)
},
render: FocusRender,
}

export const LayoutExample: StoryObj<typeof Button> = {
Expand Down

0 comments on commit b70d0cc

Please sign in to comment.