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

Attempted useMemo to no avail #303

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

samuela
Copy link

@samuela samuela commented Aug 18, 2020

This is my initial attempt at fixing #302. Unfortunately React gives an invalid hook call warning: https://reactjs.org/warnings/invalid-hook-call-warning.html. I'm guessing the issue has something to do with have a function return a functional component. I checked and don't seem to have mismatched React versions. If anyone has any ideas, please do let me know!

We also need to upgrade dependency versions since 16.8 is the earliest React release that has hooks.

@simmerer
Copy link
Collaborator

LOVE that you're tackling this! I'll take a look.

@conorhastings
Copy link
Collaborator

believe useMemo doesn't work here because line 372 will always be newly defined, so the defaultCodeValue will change every time https://github.com/react-syntax-highlighter/react-syntax-highlighter/pull/303/files#diff-6214d870917fc8dbaf180113af76d2f1a674571612cd92e1f5500c04d159ac48R372 , using a useMemo on that with the depenency being code should work better

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

Successfully merging this pull request may close these issues.

None yet

3 participants