Skip to content
This repository has been archived by the owner on Aug 23, 2022. It is now read-only.

Native version requires react-dom #792

Open
alexesDev opened this issue May 22, 2017 · 11 comments
Open

Native version requires react-dom #792

alexesDev opened this issue May 22, 2017 · 11 comments
Labels

Comments

@alexesDev
Copy link

alexesDev commented May 22, 2017

import { Form } from 'react-redux-form/native';

requires also react-dom... becouse imports some code from src/index.js what import dom-based control...

Version: react-redux-form@1.11.1

@davidkpiano
Copy link
Owner

The only instance I could find is here:

const findDOMNode = !isNative
  ? require('react-dom').findDOMNode
  : null;

Are you sure you can't use this without react-dom?

@alexesDev
Copy link
Author

alexesDev commented May 22, 2017

I upgrade my old project. At now packager say...

Unable to resolve module `react-dom` from `/home/alexes/projects/myfresh/native-client/node_modules/react-redux-form/lib/components/control-component.js`: Module does not exist in the module map or in these directories:
  /home/alexes/projects/myfresh/native-client/node_modules
,   /home/alexes/node_modules

react-native@0.44.0
The project skeleton generated today.

@maludwig
Copy link
Contributor

maludwig commented Aug 8, 2017

I'm also getting this error. If I'm interpreting the line correctly, it's saying "If it is web, require react-dom, if not, don't. I'll try replacing it with just findDOMNode = null.

@maludwig
Copy link
Contributor

maludwig commented Aug 8, 2017

Yeah that worked. Had to restart Expo from scratch, but it worked. Literally just replace this line like this, it seems something is getting required when in needn't be:

// var findDOMNode = !_isNative2.default ? require('react-dom').findDOMNode : null;
var findDOMNode = null;

@davidkpiano
Copy link
Owner

I'll make a fix for that.

peterox pushed a commit to peterox/react-redux-form that referenced this issue Oct 26, 2017
davidkpiano added a commit that referenced this issue Nov 2, 2017
Issue #792 Fix for react native
@fhaque
Copy link

fhaque commented Jan 31, 2018

I'm getting the same error as @alexesDev using react-redux-form@1.16.5

@kylegillen
Copy link

kylegillen commented Mar 1, 2018

This still seems to be very much an issue.

I got around it by commenting out line 26 & line 36 of the control-component.js.
Then adding: findDOMNode: null after line 36.

It looks like pull request 101d3bd that was meant to fix the issue wasn't successfully merged, are the plans to address this?

@davidkpiano
Copy link
Owner

@nextriot would you be able to make a new PR for it? I can merge it in ASAP.

@kylegillen
Copy link

@davidkpiano the changes that I've made would be destructive to the rest of the project (e.g. the web side).

The issue seems to be the static analysis of 'require' statements. Just the fact that it's present in the control-component.js file is forcing the compiler to search for the component. It doesn't make a difference if the 'require' is made conditionally or not, the compiler will always do the lookup.

The fastest way I can see around it is by having a separate control-component.js file for React Native use only. Alternatively, there may be a conditional require plugin for react that you could include as a dependency then use the 'require' statement as is with minimal tweaking.

I don't know enough about the layout of the plugin yet to implement either fix however. Sorry.

Let me know if there's anything else I can help with. If you want me to make the PR regardless of the above, just say the word.

@orlando
Copy link

orlando commented Mar 7, 2018

Having this issue too with version 1.16.6

@davidkpiano
Copy link
Owner

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

No branches or pull requests

6 participants