react-native-largelist: Unable to resolve module `react-native/lib/TextInputState` RN 0.61.1

After upgrading to RN 0.61.1, I’m having this error.

error Unable to resolve module react-native/lib/TextInputState from node_modules/react-native-spring-scrollview/SpringScrollView.js: react-native/lib/TextInputState could not be found within the project.

Dev OS - Mac OS 10.14.6

Target OS - Android

Simulator and Real device

Dependencies - "react-native": "0.61.1" "react-native-largelist-v3": "^3.0.14" "react-native-spring-scrollview": "^2.0.22"

Error could be on the react-native-spring-scrollview component. I’m using it as a peer dependency and not directly.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 13
  • Comments: 15 (1 by maintainers)

Most upvoted comments

Until the problem is solved I I’ve created this script and run on postinstall for fix the problem at the moment.

THIS IS TEMPORARY AND ONLY FOR v0.61+!

Filename: scripts/react-scrollview-fix.js

const fs = require("fs");

try {
	console.log("React spring scroll view fix...");
	var rootDir = process.cwd();

	var file = `${rootDir}/node_modules/react-native-spring-scrollview/SpringScrollView.js`;
	var data = fs.readFileSync(file, "utf8");
	var dataFix = 'react-native/Libraries/Components/TextInput/TextInputState';

	if (data.indexOf(dataFix) !== -1) {
		throw "> Already fixed";
	}

	var result = data.replace(
		/react-native\/lib\/TextInputState/g,
		dataFix,
	);
	fs.writeFileSync(file, result, "utf8");
	console.log("> Done");
} catch (error) {
	console.error(error);
}

Filename: package.json

{
...
    "scripts": {
        ....
        "postinstall": "node scripts/react-scrollview-fix.js"
    }
...
}

解决方法:在node文件夹中找到react-native-spring-scrollview中的SpringScrollView.js修改下面的TextInputState -import * as TextInputState from “react-native/lib/TextInputState”; +import * as TextInputState from “react-native/Libraries/Components/TextInput/TextInputState”;

I had the same issue and this issue occurs in v0.61+ This error is a cause of the wrong path for TextInputState which has been replaced in the latest versions. so go to node_modules/react-native-spring-scrollview/SpringScrollView.js replace line 24 i.e import * as TextInputState from “react-native/lib/TextInputState”; with import * as TextInputState from “react-native/Libraries/Components/TextInput/TextInputState”; and the npm start It hope it will resolve your issue Thanks

I saw that this PR https://github.com/bolan9999/react-native-spring-scrollview/pull/40 causes backward compatibility issue with RN.

Is there any other fix planned ?

Thanks

The solution we implemented was to use patch-package to temporarily patch the package.