react-redux-form icon indicating copy to clipboard operation
react-redux-form copied to clipboard

Native version requires react-dom

Open alexesDev opened this issue 8 years ago • 11 comments

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: [email protected]

alexesDev avatar May 22 '17 13:05 alexesDev

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?

davidkpiano avatar May 22 '17 13:05 davidkpiano

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

[email protected] The project skeleton generated today.

alexesDev avatar May 22 '17 14:05 alexesDev

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 avatar Aug 08 '17 04:08 maludwig

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;

maludwig avatar Aug 08 '17 04:08 maludwig

I'll make a fix for that.

davidkpiano avatar Aug 08 '17 12:08 davidkpiano

I'm getting the same error as @alexesDev using [email protected]

fhaque avatar Jan 31 '18 21:01 fhaque

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?

kylegillen avatar Mar 01 '18 20:03 kylegillen

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

davidkpiano avatar Mar 01 '18 23:03 davidkpiano

@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.

kylegillen avatar Mar 02 '18 15:03 kylegillen

Having this issue too with version 1.16.6

orlando avatar Mar 07 '18 13:03 orlando

You can work around this: https://remarkablemark.org/blog/2017/02/25/webpack-ignore-module/

davidkpiano avatar Mar 07 '18 14:03 davidkpiano