R
R
Roman Rakzin2020-05-08 17:47:12
React Native
Roman Rakzin, 2020-05-08 17:47:12

How to run a hook inside a hook in React Native?

I need to save the data in the storage when redrawing the component.
I am trying to do so

<NavigationEvents onWillFocus={payload => ScreenUpdated(payload)} />

But inside ScreenUpdated I can't do, say
let dispatch = useDispatch()
useEffect(() => {
    dispatch(loadPosts(0,0))  //loadPosts- подгрузка актуальных данных
 }, [dispatch])


how do I interact with the repository in this case?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
forspamonly2, 2020-05-09
@forspamonly2

ScreenUpdated is called just as a function, not as a component. it does not need to be written with a capital letter and use hooks in it. pass dispatch outside and call it directly with no effect.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question