Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trying to trigger re-render of ReadingCard but tangled up in React hools #25

Open
ericop opened this issue Mar 25, 2022 · 2 comments
Open

Comments

@ericop
Copy link

ericop commented Mar 25, 2022

Hi Ben,
Over on https://github.com/ericop/bible-scout-react-native fighting for hours trying to use this global state property globalState.readingState.readingProgress and when it's updated to auto re-render the Bible text (or at minimum {JSON.stringify(globalState.readingState.readingProgress)}.
Why am I using globalState? Well I read this post https://dev.to/bytebodger/hacking-react-hooks-shared-global-state-553b and it seemed better than passing that prop down through about 7 levels of components via props. Also I tried just passing it down through props but got stuck trying to get the props in on my <MyDrawer.Screen name="LawAndProphets" ...> in a way that I could access in export default function ReadingCard(props: any) { . I experimented with ideas like https://reactnavigation.org/docs/screen#children but still couldn't get access to the props as I expected.

I've thought of trying to re-do this global state with https://github.com/pmndrs/zustand but the prevailing advice seems to be "use hooks and props when you can to avoid unneeded complexity" so I wanted to get it functional this way first.

It seems God has give you wit and expertise in all the React front-end Comp-Sci goodness, and any direction and help you could give me to resuscitate my app comes with an immense amount of gratitude.

@ericop
Copy link
Author

ericop commented Mar 25, 2022

Reading over https://www.thoughtworks.com/radar/languages-and-frameworks/react-hooks reminded me that I should probably also to a test run of using https://reactjs.org/docs/context.html#reactcreatecontext or https://reactjs.org/docs/composition-vs-inheritance.html#containment so I plan to experiment with that this weekend.

@ericop
Copy link
Author

ericop commented Mar 26, 2022

I got it working most of the way with https://github.com/pmndrs/zustand but I'd still appreciate your input on the structure and state management setup as times allows you, and as you weigh out how to glorify Christ the best with your limited time 😉.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant