Flagsmith / Flagsmith/react-navigation-focus-render

Hook and React.memo Version

Aperta
#1 3 commenti 0 reazioni 1 assegnatario Rivendicata da @kyle-ssg Vedi su GitHub
Lingua principale
TypeScript
Stelle
13
Fork
1
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Thanks for your awesome library.
My project can't use react-navigation 5. so I cloned your source as hook version.
I don't know yet how create this with useMemo instead of React.memo.
How about this?

```
import React, { ReactElement } from 'react'
import { useIsFocused } from 'react-navigation-hooks'

type RendererProps = Props & {
isFocused: boolean
}

type IRenderer = React.FC

const Renderer: IRenderer = ({ children, Wrapper }) => {
return Wrapper ? {children} : (children as ReactElement)
}

const MemorizedRender = React.memo(Renderer, (_, { isFocused }) => {
return !isFocused
})

export const FocusRender: IFocusRender = ({ children, Wrapper }) => {
const isFocused = useIsFocused()

return (

{children}

)
}
```

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.