question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

is it a good idea to use `__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED`?

See original GitHub issue

As I understand, React bindings of this package are using __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED variable from react package.

It looks a little bit dangerous, doesn’t it? It looks like it could break after any minor update of React.

Monkey patching of React internals looks are even more dangerous for me.

Is React bindings of suitable for production usage?

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:4
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

18reactions
Nicifycommented, Sep 7, 2022
3reactions
CodyJasonBennettcommented, Sep 13, 2022

__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED is not guaranteed by the same semver as react or react-dom, but alongside internals like react-reconciler. This is why react and react-dom are updated in lock-step, with user-land implementations lagging behind to support a wide dependency range.

pmndrs/its-fine abstracts Fiber internals specific to react-reconciler since I found it annoyingly common for renderer authors to leverage internal fields to support different platforms (e.g. https://github.com/facebook/react/issues/14983, https://github.com/pmndrs/react-three-fiber/issues/43). By outsourcing this to an external package, we can focus on well-supported patterns and semver for interop. Here, we control the reconciler version.

This package has a different scope though. Signals introduce a new state primitive without explicit component bindings; __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED provides the mechanism to observe components as React sees them (these are shared globals and update via rapid mutation) and invoke hooks inside the context of that component. The latter is the most error-prone part since it does not follow rules-of-hooks (you can forget to update state), but I’ve covered withstanding issues with this implementation in #130.

In any case, having useSignal accept an actual Signal as outlined in https://github.com/preactjs/signals/issues/86#issuecomment-1239687550 enables it to do the same thing as the component bindings, with the safeguard that you’re working entirely within a component. My worry for this case would be tree-shaking of component bindings – you no longer need them and probably don’t want them. Is there a way to make this opt-in alongside a JSX transform (related: #115)?

Read more comments on GitHub >

github_iconTop Results From Across the Web

is it safe to use __ ...
No, it's not safe to use. That's why it has a scary name. We offer no guarantees about what will happen if you...
Read more >
I want to use the undocumented property React ...
I want to use the undocumented property React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED which holds some interesting insights and ...
Read more >
r/programmingcirclejerk - is it safe to use ... - Reddit
We at the js land don't use any pesky "private fields". We use "la closure" instead. const createFoo = (() => { class...
Read more >
React Source code: What does it mean by "real internal ...
No, it's not safe to use. That's why it has a scary name. We offer no guarantees about what will happen if you...
Read more >
React: Don't Operation or You'll Get Fired | by Programmer Ahui
Summary. This article explained how react and react-dom use the enigmatic internal variable __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED. He can pass ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found