Skip to content

Conversation

@tomekvenits
Copy link

Regarding support for preact in issue #387

I looks like overmind imports ReactCurrentOwner from __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED that is exported in React.

I found ReactCurrentOwner in React:
https://github.com/facebook/react/blob/master/packages/react/src/ReactCurrentOwner.js

I replaced it with it's value and it works :)

I think its good idea to remove variables with name like this from source code :D

@christianalfoni
Copy link
Member

Hi there @venits !

Ah, this is great :)

Though removing it will also remove the names of the components in the devtools when using React. So we should make it still work.

So what I would suggest is rather changing to:

const ReactCurrentOwner = (react as any).__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED && (react as any).__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner

That way it will work the same for React, and then names of components are just dropped in the devtools when using Preact 😄

@tomekvenits
Copy link
Author

@christianalfoni yep, you are right 👍

I added your change and it works :) Thank you 🎉

@tomekvenits
Copy link
Author

Ahh, this code throws:

Attempted import error: '__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' is not exported from 'react' (imported as 'react').

It may be hard to overcome this ;/

@christianalfoni
Copy link
Member

Ah, that sucks, but you could really just copy the overmind-react folder to overmind-preact and make the changes there. No problem to just support a second package 😄

@smashercosmo
Copy link

smashercosmo commented Aug 28, 2020

Seems like this has been addressed in the latest Preact
preactjs/preact#2692

@tomekvenits
Copy link
Author

Yep 🎉

Screenshot 2020-08-26 at 21 20 22

I tested it on:

"preact": "^10.4.8",
"overmind": "^25.0.1",
"overmind-react": "^26.0.1",

and it works great 👍

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.

3 participants