动态创建不会在每次更改时刷新DOM的反应组件

时间:2018-02-22 00:38:19

标签: javascript reactjs redux

我正在使用React应用程序,我们正在渲染从另一个应用程序传入的未知数量的表单元素。我有代码设置来引入所有可能的组件并在需要时动态渲染每个组件(下面),但每次我做任何更改(即在文本字段中输入文本,单击复选框等),每个表单元素都会更新。我不确定如何解决这个问题,因为渲染是在map函数中完成的,我无法摆脱map函数,因为我们不知道将要发送的元素是什么或有多少渲染。我正在使用redux,因此无法充分使用shouldComponentUpdate,但我在public class Count { public static void main(String[] args) { File sFile = new File("s.txt"); FileReader in; BufferedReader readFile; String sourceCode; int amountOfWords = 0; int amountOfChars = 0; try { in = new FileReader(sFile); readFile = new BufferedReader(in); while ((sourceCode = readFile.readLine()) != null) { String[] words = sourceCode.split(" "); amountOfWords = amountOfWords + words.length; for (String word : words) { amountOfChars = amountOfChars + word.length(); } } System.out.println("Amount of Chars is " + amountOfChars); System.out.println("Amount of Words is " + (amountOfWords + 1)); System.out.println("Average Word Length is "+ (amountOfChars/amountOfWords)); readFile.close(); in.close(); } catch (FileNotFoundException e) { System.out.println("File does not exist or could not be found."); System.err.println("FileNotFoundException: " + e.getMessage()); } catch (IOException e) { System.out.println("Problem reading file."); System.err.println("IOException: " + e.getMessage()); } } } 中使用了{pure: true}选项,没有运气。关于如何做到这一点的任何想法?

connect

0 个答案:

没有答案