Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6214

Can I use a React hook directly as a prop in JSX?

$
0
0

I managed to get it with no warnings from TSLint. I will not be able to test it until several days since I'm heavily refactoring the app.

I never seen useCustomHook() passed directly in provider's value in tutorials or docs. It seems much more simple to write. Is it a bad practice, or what ?

import useCustomHook, {customHookInitialValues, UseCustomHookType} from './useCustomHook'export const Context = createContext<UseCustomHookType>({customHookInitialValues})export const ContextProvider = ({ children }: Props) =><Context.Provider value={useCustomHook()}>{children}</Context.Provider>

Viewing all articles
Browse latest Browse all 6214

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>