File tree Expand file tree Collapse file tree 4 files changed +292
-159
lines changed
Expand file tree Collapse file tree 4 files changed +292
-159
lines changed Original file line number Diff line number Diff line change 1111 "no-console" : " error" ,
1212 "no-array-sort" : " off" ,
1313 "rules-of-hooks" : " error" ,
14+ "react/jsx-key" : " error" ,
1415 "react-in-jsx-scope" : " off" ,
1516 // @TODO these rules should be enabled, and the violations fixed
1617 "no-unsafe-type-assertion" : " off"
3031 "rules" : {
3132 "jsx-no-new-object-as-prop" : " off" ,
3233 "jsx-no-new-array-as-prop" : " off" ,
33- "jsx-no-jsx-as-prop" : " off"
34+ "jsx-no-jsx-as-prop" : " off" ,
35+ "jsx-no-new-function-as-prop" : " off" ,
3436 }
3537 }
3638 ]
Original file line number Diff line number Diff line change 11import type { PortableTextMarkComponent } from '@portabletext/react'
22
3- import { useCallback } from 'react'
43
54interface SpeechSynthesisMark {
65 _type : 'speech'
@@ -15,15 +14,15 @@ export const SpeechSynthesis: PortableTextMarkComponent<SpeechSynthesisMark> = (
1514 value,
1615} ) => {
1716 const pitch = value ?. pitch || 1
18- const handleSynthesis = useCallback ( ( ) => {
19- const msg = new SpeechSynthesisUtterance ( )
17+
18+
19+ return (
20+ < button type = "button" onClick = { ( ) => {
21+ const msg = new SpeechSynthesisUtterance ( )
2022 msg . text = text
2123 msg . pitch = pitch
2224 window . speechSynthesis . speak ( msg )
23- } , [ text , pitch ] )
24-
25- return (
26- < button type = "button" onClick = { handleSynthesis } >
25+ } } >
2726 { children }
2827 </ button >
2928 )
Original file line number Diff line number Diff line change 11import type { PortableTextMarkComponent } from '@portabletext/react'
22
33import { Popover , Text } from '@sanity/ui'
4- import { useCallback , useState } from 'react'
4+ import { useState } from 'react'
55
66interface DefinitionMark {
77 _type : 'definition'
@@ -10,8 +10,6 @@ interface DefinitionMark {
1010
1111export const TermDefinition : PortableTextMarkComponent < DefinitionMark > = ( { value, children} ) => {
1212 const [ isOpen , setOpen ] = useState ( false )
13- const handleOpen = useCallback ( ( ) => setOpen ( true ) , [ setOpen ] )
14- const handleClose = useCallback ( ( ) => setOpen ( false ) , [ setOpen ] )
1513 return (
1614 < Popover
1715 animate
@@ -25,7 +23,7 @@ export const TermDefinition: PortableTextMarkComponent<DefinitionMark> = ({value
2523 </ Text >
2624 }
2725 >
28- < span style = { { textDecoration : 'underline' } } onMouseOver = { handleOpen } onMouseOut = { handleClose } >
26+ < span style = { { textDecoration : 'underline' } } onMouseOver = { ( ) => setOpen ( true ) } onMouseOut = { ( ) => setOpen ( false ) } >
2927 { children }
3028 </ span >
3129 </ Popover >
You can’t perform that action at this time.
0 commit comments