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

Using two different renderers in a same script #5768

Closed
Yomguithereal opened this issue Jan 2, 2016 · 2 comments
Closed

Using two different renderers in a same script #5768

Yomguithereal opened this issue Jan 2, 2016 · 2 comments

Comments

@Yomguithereal
Copy link

Hello React team. Due to the way React injects its dependencies (notably the Component one), one cannot use two different renderers in a node.js scripts. Let's say, for instance, that I need to use both react-blessed and react-dom/server because I display a nice CLI interface and then render some html after a HTTP request, this will crash because the second renderer will override the first's one dependencies.

Is there a solution I would have overlooked here?

Related to Yomguithereal/react-blessed#43.

@jimfb
Copy link
Contributor

jimfb commented Jan 2, 2016

react-blessed appears to be calling ReactInjection, which is part of React DOM. I think the root of your problem is this erroneous dependency, whereby you are relying on global state within the core of the renderer. Ultimately react-blessed is not rendering to the DOM and should therefore not be calling into the DOM code (it should be it's own renderer, using things from renderers/shared but not from renderers/dom). I think that's what @sebmarkbage would say (cc him), also cc @spicyj for comments.

@sophiebits
Copy link
Collaborator

It is true that you can't (currently) have two renderers sharing the core React modules because we have this global state. (ReactInjection has nothing to do with it.) We would like to resolve this longer-term either by encouraging flat builds where each renderer has its own copy of React bundled in, or perhaps by changing the React core to make the modules instantiable and not store global state.

You may be able to work around this problem by loading two completely independent copies of React. Hope that will work for you – though if it doesn't we probably won't be up for making significant changes to support this because alternate backends are not an active priority for us right now because of time constraints. Hopefully we can support this better one day though.

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

3 participants