CodeConvo / react /react.c2i.test.jsonl
jiebi's picture
Upload CodeConvo dataset
c2b8f63 verified
{"query_id": "q-en-react-04add7cc87400d8c778139879b72fad39cd35a704885942893986892760d74e7", "query": "COMMANDS_TO_RUN+=('./scripts/circleci/build.sh') COMMANDS_TO_RUN+=('yarn test-build --runInBand') COMMANDS_TO_RUN+=('yarn test-build-prod --runInBand') <ins> COMMANDS_TO_RUN+=('./scripts/circleci/upload_build.sh') </ins> fi if [ $((3 % CIRCLE_NODE_TOTAL)) -eq \"$CIRCLE_NODE_INDEX\" ]; then", "positive_passages": [{"docid": "doc-en-react-d8ee1ccb8399f810362f1a0abd267e8242d6b55ced92ad6d4ce964cd672b1c32", "text": "It looks like this: It happened two times on random commits, and I don't see a pattern. Probably caused by me changing how tasks are distributed between parallel nodes in I don't understand why would try to run before a build exists though (if that's what's happening?)\nI think this one would require some experience with CircleCI. I don't have any pointers as to where to start: I don't understand why it's failing myself. So it's not a very beginner-friendly issue (I marked the difficulty as medium for that reason).\nAnother example:\nI want to work on this. After doing some research on circleci document, I didn't find the document said about parallel test and deployment sequence. I'm curious about how circleci deal with parallel test and deployment sequence. I think there are two situations: all parallel test finishes, run deployment sequence. If this is true, I think it won't cause current test error. container runs deployment after the container's test finished. I guess it is more likely in this case. Sometimes it passed, it's because node 2 already built file. Sometimes it failed because node 2 didn't build file yet. So I think maybe that's because each container will run deployment after that node test finished. If the situation is as above, I come up with two solutions. we want to keep current test flow, we can try to keep each node builds time balance. this test at first, then run other test parallel. reference link:\nOnly node 2 does a full build. So I don't understand how deployment on other nodes could work at all.\nOr do nodes share the file system?\nI think nodes share the file system. Otherwise, it should fail every time. It will be easier to debug if we can add more log, like current build time and .\nWould it make sense to change the upload script to only run on the second node?\nYep, I think so, because in the document I can't ensure whether deployment stage is triggered after all parallel test finished.\nCan we just put the deployment command right into the test command? Is there any benefit to separating them?\nI think it's also workable, but may lead misunderstanding. Cause we put build process to test stage. Or we can try to use stage. Run at compile stage, so we can promise and stages have needed file.", "commid": "react_issue_11657", "tokennum": 500}], "negative_passages": []}
{"query_id": "q-en-react-04add7cc87400d8c778139879b72fad39cd35a704885942893986892760d74e7", "query": "COMMANDS_TO_RUN+=('./scripts/circleci/build.sh') COMMANDS_TO_RUN+=('yarn test-build --runInBand') COMMANDS_TO_RUN+=('yarn test-build-prod --runInBand') <ins> COMMANDS_TO_RUN+=('./scripts/circleci/upload_build.sh') </ins> fi if [ $((3 % CIRCLE_NODE_TOTAL)) -eq \"$CIRCLE_NODE_INDEX\" ]; then", "positive_passages": [{"docid": "doc-en-react-e735e4bcc04de4af8c79e9b836d6bd97863c094232bf2c644c6a4d2b1d364c3b", "text": "The interesting part is our regular tests don't need compilation. If \"compile\" stage has to run before any other stages then we'll wait unnecessarily. I'd prefer to have a single script that does everything than to buy into CircleCI specific terminology unless it buys us something real good (e.g. parallelism was very useful). Maybe can try this:\nOK, I understand your consideration. I think this fix will work. Just tell me if anything can help.", "commid": "react_issue_11657", "tokennum": 103}], "negative_passages": []}
{"query_id": "q-en-react-08d1f795b0b106899d6c8039e2ec679bc51dc211e6341a0b87ccd95359bef026", "query": "} } while (nextEffect !== null) { <ins> if (__DEV__) { setCurrentFiber(nextEffect); } </ins> const effectTag = nextEffect.effectTag; if (effectTag & (Update | Callback)) {", "positive_passages": [{"docid": "doc-en-react-32fed7447c33e1c49292377f28ba22b1f003566fcb0c01f418bb8b8e131f1319", "text": "I've noticed a strange bug with the react redux opt-in. If i use it with a connected class component, everything is ok: If i use it with a connected functional component that use with , i obtain a strange error: in method. I create a codepen to reproduce the issue: PS: Sorry for the cors error, but i don't find the way to add as cdn\nI believe the issue here is that expects the second argument to be a function that returns the reference: See: for more information about the API of the hook. Maybe the error thrown could be more clear?\nYou're right, accept a function as second argument. A warning on wrong argument type could be a good idea.\nIll take this issue on\nSure\ni get TypeError: React.useImperativeMethods is not a function in 16.8.0-alpha.1 but when back to 16.7.0-alpha.2 not get this error\nThe hook was renamed in this PR: Most likely between the 16.7 alpha and 16.8 alpha\nYeah, it was renamed.\nyes it work good after rename it where i can get changes between alpha version ?\nCommit log. We don't write changelogs for alphas.\nI'm taking this in since we want to get Hooks out sooner.\nalright np", "commid": "react_issue_14629", "tokennum": 277}], "negative_passages": []}
{"query_id": "q-en-react-09ac2aa728271f2b62d4a25409bcd2310501e5004b301546250b41af7ae6ae73", "query": "const MAX_SIZE = 500; const PAGE_SIZE = 50; <del> function createRecord<K, V>(key: K): EmptyRecord<K, V> { </del> <ins> function createRecord<K>(key: K): EmptyRecord<K> { </ins> return { status: Empty, suspender: null,", "positive_passages": [{"docid": "doc-en-react-6b3c5af2ada23f47aa80eedc03ca3a83d950eba15ef87f3dd6836f67ab1f9949", "text": "In we landed a change to the Flow types in , making the types for the various types recursive with their and properties. On that PR we may have been running an older version of Flow - I'm not having luck finding the record of when Flow ran for that PR, so not sure. In any case, that PR was merged even though it had the recursive Flow type definitions, plus one or more Flow errors which were unrelated and not detected. The problem with the recursive type definitions is that recent versions of Flow will go into an infinite loop if they try to infer types which are recursive. The solution may be to add more detail to those types, but to unblock things we temporarily made them looser type definitions.", "commid": "react_issue_12941", "tokennum": 154}], "negative_passages": []}
{"query_id": "q-en-react-0a2bffbae851a79b71c900082e658405d8903c5f7cd4de93488a70d0627ec09d", "query": "return newHead; } <del> function load<V>(emptyRecord: EmptyRecord, suspender: Promise<V>) { const pendingRecord: PendingRecord<V> = (emptyRecord: any); </del> <ins> function load<K, V>(emptyRecord: EmptyRecord<K>, suspender: Promise<V>) { const pendingRecord: PendingRecord<K, V> = (emptyRecord: any); </ins> pendingRecord.status = Pending; pendingRecord.suspender = suspender; suspender.then( value => { // Resource loaded successfully. <del> const resolvedRecord: ResolvedRecord<V> = (pendingRecord: any); </del> <ins> const resolvedRecord: ResolvedRecord<K, V> = (pendingRecord: any); </ins> resolvedRecord.status = Resolved; resolvedRecord.suspender = null; resolvedRecord.value = value;", "positive_passages": [{"docid": "doc-en-react-6b3c5af2ada23f47aa80eedc03ca3a83d950eba15ef87f3dd6836f67ab1f9949", "text": "In we landed a change to the Flow types in , making the types for the various types recursive with their and properties. On that PR we may have been running an older version of Flow - I'm not having luck finding the record of when Flow ran for that PR, so not sure. In any case, that PR was merged even though it had the recursive Flow type definitions, plus one or more Flow errors which were unrelated and not detected. The problem with the recursive type definitions is that recent versions of Flow will go into an infinite loop if they try to infer types which are recursive. The solution may be to add more detail to those types, but to unblock things we temporarily made them looser type definitions.", "commid": "react_issue_12941", "tokennum": 154}], "negative_passages": []}
{"query_id": "q-en-react-0a56b098a6dc9769a24fea108d6459673db4cd78868d1d5c0b9e3d7ebda56af0", "query": "var propName = propertyInfo.propertyName; // Must explicitly cast values for HAS_SIDE_EFFECTS-properties to the // property type before comparing; only `value` does and is string. <del> // Must set `value` property if it is not null and not yet set. </del> if (!propertyInfo.hasSideEffects || <del> ('' + node[propName]) !== ('' + value) || !node.hasAttribute(propertyInfo.attributeName)) { </del> <ins> ('' + node[propName]) !== ('' + value)) { </ins> // Contrary to `setAttribute`, object properties are properly // `toString`ed by IE8/9. node[propName] = value;", "positive_passages": [{"docid": "doc-en-react-02f66d4e335d6ddaefdaada0c5924337c1569646c887a9e0f46ffcf90b1e6c5d", "text": "Appears to be working in Firefox but at least Chrome & Safari are broken. Should be a really recent regression so very few possible changes to blame... Easiest repo: the todo list on our homepage.\nJust a heads up but this still seems to be an issue even on 15.4.1. I've been struggling to reproduce this because it seems to be some sort of ninja bug. Nevertheless, I was wondering if anyone is still dealing with this problem?\nI haven't seen anything.\nI'm still seeing this issue.\nPlease open a new issue with a simplified repro case if you're still seeing this!", "commid": "react_issue_6445", "tokennum": 133}], "negative_passages": []}
{"query_id": "q-en-react-16df93b253c4ae0b30bb344813993801464d6751c98c5e66bbc280fe7ae5eafe", "query": "</span> {isEditable ? ( <EditableValue <del> dataType={dataType} </del> <ins> initialValue={value} </ins> overrideValueFn={((overrideValueFn: any): OverrideValueFn)} path={path} <del> initialValue={value} </del> /> ) : ( <span className={styles.Value}>{displayValue}</span>", "positive_passages": [{"docid": "doc-en-react-473a4b58713ca7c8d0e8060a45651ad2625b8e108683a3fbb58f5695d87bc14b", "text": "Do you want to request a feature or report a bug? Report a bug What is the current behavior? The hook's value is shown as in React DevTools if the value is a string or a number. Clicking on the bug icon prints the correct values to console. ! If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. CodeSandbox: Direct link to page so you can see the DevTools: What is the expected behavior? The DevTools should show the correct value of the hook. Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React? React 16.9.0. Google Chrome [Version 77.0.3865.90 (Official Build) (64-bit)] running on Linux x64. This issue appeared after version 4.1.0 (9/19/2019) of the DevTools Chrome extension. Might be same bug as but this one appears without any complicated reproduction steps.\nLooks like the issue also appears with boolean values.\nHaving the same problem. The extension worked fine after I downgraded React to version 16.8.6\nI think the only significant difference between React v16.8 and v16.9 is that v16.9 injects the function DevTools uses to support editable hooks (in other words, DevTools is using a different code path when you run v16.8 vs v16.9). I think that means this bug is probably related to somehow. Will dig in more.\nShould be fixed by\nThis fix will be released with 4.1.1 (sometime soon)\nThis fix has just been published to NPM and posted to Chrome/Firefox as v4.1.1", "commid": "react_issue_16859", "tokennum": 400}], "negative_passages": []}
{"query_id": "q-en-react-17293207531c6352290b933d4fe9d85d17a1553684093dd654f4cb65ec631b07", "query": "do { lastID = internalGetID(current); current = current.parentNode; <del> invariant( current != null, 'findFirstReactDOMImpl(...): Unexpected detached subtree found when ' + 'traversing DOM from node `%s`.', nodeID ); </del> <ins> if (current == null) { // The passed-in node has been detached from the container it was // originally rendered into. return null; } </ins> } while (lastID !== reactRootID); if (current === containersByReactRootID[reactRootID]) {", "positive_passages": [{"docid": "doc-en-react-6746ac08815bbf89a554f2599c24efc7ee4f226755f4ae042a57183292a2342c", "text": "Since upgrading from beta3 to rc1 I've seen this error a few times in production. Haven't been able to trace the source yet though. cc\nI was unmounting a root during a keyboard event which caused this to happen. I think this has always been a problem? Perhaps we've only been lucky... leaving open just to be sure. EDIT: Could it make sense to have something along the lines of ? Allowing you to schedule things to occur as soon as the current transaction ends.\nThis invariant was new in this release. We also hit one case at FB that I haven't yet investigated. Probably need to change something for the final release.\nI have seen this on RC1 can't find a sequence of actions to repeat it.\nI'm running into this issue as well when conditionally rendering based on state. Not sure how to boil it down to a simple reproducible bug report yet.\nMy issue only happens when I am leveraging FastClick. Didn't happen before 0.14.\nI've found it is because the events are handled in a different order with fastclick, so the batching gets weird...\ne.g. click gets fired before touchEnd, so click handler setState to remove subtree, and then react tries to do something with it in touch end perhaps?", "commid": "react_issue_4865", "tokennum": 278}], "negative_passages": []}
{"query_id": "q-en-react-17293207531c6352290b933d4fe9d85d17a1553684093dd654f4cb65ec631b07", "query": "do { lastID = internalGetID(current); current = current.parentNode; <del> invariant( current != null, 'findFirstReactDOMImpl(...): Unexpected detached subtree found when ' + 'traversing DOM from node `%s`.', nodeID ); </del> <ins> if (current == null) { // The passed-in node has been detached from the container it was // originally rendered into. return null; } </ins> } while (lastID !== reactRootID); if (current === containersByReactRootID[reactRootID]) {", "positive_passages": [{"docid": "doc-en-react-19961fc470123ba131df0c13acdc16dca9ae2f0bc85b5a2da9d0662a1783f6d5", "text": "In this repro, I created 2 buttons and only one is rendered at a time. One button's click handler is hooked up to React's synthetic \"click\" event while the other is hooked up to the native \"click\" event. Even though only one button is rendered at a time, a single click is triggering both click events. This bug can be hit by apps that mix React components with non-React controls (e.g. jQuery UI). I reproed this in Chrome with React 0.13.2. to the button labeled \"One\" Expected: There's a button rendered labeled \"Two\" Actual: The rendered button still has the label \"One\" If you open the console, you'll see \"goToTwo\" and \"goToOne\" which indicates that the \"One\" button's click handler ran and then the \"Two\" button's click handler ran (even though we never saw button \"Two\"\").\nI experimented more and came up with another repro: In this one, you click on a button with a native \"click\" handler which causes the button to go away and an input field to be rendered. It results in this exception: From these 2 repros, it seems something strange is going on when calling from within a native \"click\" handler.\nIt works if you add to the event handler.\nThanks for the workaround. Is the behavior without the by design? It looks like the bad behavior is being caused by the rerender happening synchronously within the native \"click\" handler.\nThis looks bad. We don't do a great job interacting with native events. Sebastian wrote a post about this once-upon-a-time, how native and synthetic event systems are, by and large, not interoperable. Even so, I can't see a reason we should fatal like this. Do you understand what's going wrong here? What a fix might look like?\nThis happens when we handle a click event from a node that's been removed in between when the event is triggered and when React receives it. How should we deal with the case that events fire on detached elements? Should we ignore events for nodes that aren't in the document? I don't think the bug is easily fixable otherwise because we don't have the old event handler after the reconcile that removes that node.\nHere are some additional details about the impact of the bug.", "commid": "react_issue_3790", "tokennum": 505}], "negative_passages": []}
{"query_id": "q-en-react-17293207531c6352290b933d4fe9d85d17a1553684093dd654f4cb65ec631b07", "query": "do { lastID = internalGetID(current); current = current.parentNode; <del> invariant( current != null, 'findFirstReactDOMImpl(...): Unexpected detached subtree found when ' + 'traversing DOM from node `%s`.', nodeID ); </del> <ins> if (current == null) { // The passed-in node has been detached from the container it was // originally rendered into. return null; } </ins> } while (lastID !== reactRootID); if (current === containersByReactRootID[reactRootID]) {", "positive_passages": [{"docid": "doc-en-react-7851a482df6560c8b9755474dda32fba2e00952e4178b5bb7f60e2baae6ce704", "text": "It sounds like this bug is likely to trigger when you use a non-React component (e.g. jQuery UI) in a React single page application and the non-React component triggers a navigation within the app.\nThanks for an excellent bug report and good repro case! I think this happens because we use the \"root id\" to determine which element was clicked. In the repro case there is no \"key\" as part of the root ID for two reasons: 1) It is not a child of a container (multichild) so it doesn't get a key to the root ID. 2) It doesn't have a unique key and doesn't need one because it the button is of a different type. If I make sure that a key is used as part of the root ID the problem is solved: So the problem in the repro isn't that we're firing on a removed node, it is that we're firing the event on the new node. This would be solved if we used a unique ID per instance to identify event handlers instead of a generate root that is non-unique. Which I think we wanted to do anyway. Is there another repro that shows a different issue?", "commid": "react_issue_3790", "tokennum": 253}], "negative_passages": []}
{"query_id": "q-en-react-20ce2b27ca5a000860017820efe9643aa6f9e00c779b16e6ed8aeeb6eb93ec59", "query": "Markdown is a simple way to format your text inline. For example, surrounding text with asterisks will make it emphasized. <del> First, add the third-party **Showdown** library to your application. This is a JavaScript library which takes Markdown text and converts it to raw HTML. This requires a script tag in your head (which we have already included in the React playground): </del> <ins> First, add the third-party library **marked** to your application. This is a JavaScript library which takes Markdown text and converts it to raw HTML. This requires a script tag in your head (which we have already included in the React playground): </ins> ```html{7} <!-- index.html -->", "positive_passages": [{"docid": "doc-en-react-bda68aba5b773f0e231d8ae9f598c5dea11ff75961a86d42353566558f7ff8f7", "text": "Since copy+pasting our code makes it too easy for people to XSS themselves, lets just add a comment in there about it.\nPR at - let me know if that's what you had in mind!\nMy intuition is that it makes more sense to fix the example (call a sanitization library) or to change the example completely (demonstrate something else that is safer). It looks really bad to have a security warning on the homepage of the react site. Makes it seem like our framework encourages unsafe operations, rather than a safe-by-default way of doing things.\nShould switch the demo to use a different library like markdown-js that escapes everything and doesn't support HTML:\nmarkdown-js looks good. First attempt: ,output Code licensed if someone wants to turn this into a coherent example; I've signed the CLA.\nThat's a good suggestion too :) - what are your thoughts? I'm happy to change the example to use like people have suggested above. nice usage example :+1:\nUh yea, that sounds fine to me. This behavior is definitely non-standard markdown but it's an example so not a big deal. We should probably do the same for the tutorial while we're here. And it's on cdnjs so that's all pretty easy:\nJust going to use marked instead, which I'm already familiar with and has an option to sanitize input.", "commid": "react_issue_3501", "tokennum": 304}], "negative_passages": []}
{"query_id": "q-en-react-23f2eca2ce19c88138563acc5ba75562e4835e85142f0959692bbc72882b58d6", "query": "); } break; <ins> case 'option': transaction.getReactMountReady().enqueue( optionPostMount, this ); </ins> } return mountImage;", "positive_passages": [{"docid": "doc-en-react-02f66d4e335d6ddaefdaada0c5924337c1569646c887a9e0f46ffcf90b1e6c5d", "text": "Appears to be working in Firefox but at least Chrome & Safari are broken. Should be a really recent regression so very few possible changes to blame... Easiest repo: the todo list on our homepage.\nJust a heads up but this still seems to be an issue even on 15.4.1. I've been struggling to reproduce this because it seems to be some sort of ninja bug. Nevertheless, I was wondering if anyone is still dealing with this problem?\nI haven't seen anything.\nI'm still seeing this issue.\nPlease open a new issue with a simplified repro case if you're still seeing this!", "commid": "react_issue_6445", "tokennum": 133}], "negative_passages": []}
{"query_id": "q-en-react-265eefe968d1d4375df2787a14b2d59073b9eabf6c6692729e0e6ca4fd992a55", "query": "\"private\": true, \"scripts\": { \"build\": \"cross-env NODE_ENV=production yarn run build:chrome && yarn run build:firefox && yarn run build:edge\", <del> \"build:dev\": \"cross-env NODE_ENV=development yarn run build:chrome && yarn run build:firefox && yarn run build:edge\", </del> <ins> \"build:dev\": \"cross-env NODE_ENV=development yarn run build:chrome:dev && yarn run build:firefox:dev && yarn run build:edge:dev\", </ins> \"build:chrome\": \"cross-env NODE_ENV=production node ./chrome/build\", \"build:chrome:crx\": \"cross-env NODE_ENV=production node ./chrome/build --crx\", \"build:chrome:dev\": \"cross-env NODE_ENV=development node ./chrome/build\",", "positive_passages": [{"docid": "doc-en-react-593d62aabd411439866c817fb1e4ea64d8a16337e89ffadf74b971d86d744b40", "text": "<!-- Please provide a clear and concise description of what the bug is. Include screenshots if needed. Please test using the latest version of the relevant React packages to make sure your issue has not already been fixed. --React Dev Tools version: 4.6.0 I'm not sure there is a problem with within package, or it's just my misunderstand how it works, but script create production build. Command above runs a each script (per browser) in which is set to . run in creates minified version of files. where has set to . Each step in should be replaced from to\nSend a PR? This does look odd.\nSure, I'll take a look at it tomorrow, it's looks odd and incorrectly but need to check there isn't any trap with that", "commid": "react_issue_18512", "tokennum": 169}], "negative_passages": []}
{"query_id": "q-en-react-29ec3ef453ea77c05be139bcdc942d399967d4ab420fb3a3567007bf61309356", "query": "return markup; }, <ins> _constructComponent: function(publicProps, publicContext) { if (__DEV__) { ReactCurrentOwner.current = this; try { return this._constructComponentWithoutOwner(publicProps, publicContext); } finally { ReactCurrentOwner.current = null; } } else { return this._constructComponentWithoutOwner(publicProps, publicContext); } }, _constructComponentWithoutOwner: function(publicProps, publicContext) { var Component = this._currentElement.type; if (shouldConstruct(Component)) { return new Component(publicProps, publicContext, ReactUpdateQueue); } else { return Component(publicProps, publicContext, ReactUpdateQueue); } }, </ins> performInitialMountWithErrorHandling: function( renderedElement, nativeParent,", "positive_passages": [{"docid": "doc-en-react-ca19df289e02684e61e07a528776d59aafa3f9ae31aa0dfa1ca6abf5d058dfe3", "text": "There appears to have been a change in how is generated between 0.13 and 0.14 which is causing a number of our shallow rendered tests to fail when upgrading because the deepEquals fails on the property. Here is a simple example component which exhibits the issue.\nI've been seeing some similar issues with shallow rendering. My current (messy - sorry!) workaround is this: Let me know if that helps! My version currently breaks some of the Jest tests, but I'm happy to work on this some more and submit a PR.\nThank you very much for this, it's been a tremendous help! While this solved the problem for my test case above it still failed on a large number of our more complex tests. I've been iterating on it and once I have all of our tests passing I'll add the updated version.\nHere is the updated workaround, it works for our 238 tests of varying complexity but I'd be interested to see if it passes all of your tests as well.\nAwesome! If you don't mind trying, what happens if you do and then use the earlier ?\nMuch cleaner thanks, I guess I was in my head too much :)\nI prefer applying a monkey patch, until we have this fixed in react by wrapping TestUtils in my own module:\nThis should be fixed by .", "commid": "react_issue_5292", "tokennum": 278}], "negative_passages": []}
{"query_id": "q-en-react-2be836c71d84ab1ae1a8bac90b0a5eeae0f38355b7cedb761ac3c10c9092c0d9", "query": "<script type=\"text/javascript\" src=\"/react/js/react.js\"></script> <script type=\"text/javascript\" src=\"/react/js/JSXTransformer.js\"></script> <script type=\"text/javascript\" src=\"/react/js/live_editor.js\"></script> <del> <script type=\"text/javascript\" src=\"/react/js/showdown.js\"></script> </del> </head> <body>", "positive_passages": [{"docid": "doc-en-react-bda68aba5b773f0e231d8ae9f598c5dea11ff75961a86d42353566558f7ff8f7", "text": "Since copy+pasting our code makes it too easy for people to XSS themselves, lets just add a comment in there about it.\nPR at - let me know if that's what you had in mind!\nMy intuition is that it makes more sense to fix the example (call a sanitization library) or to change the example completely (demonstrate something else that is safer). It looks really bad to have a security warning on the homepage of the react site. Makes it seem like our framework encourages unsafe operations, rather than a safe-by-default way of doing things.\nShould switch the demo to use a different library like markdown-js that escapes everything and doesn't support HTML:\nmarkdown-js looks good. First attempt: ,output Code licensed if someone wants to turn this into a coherent example; I've signed the CLA.\nThat's a good suggestion too :) - what are your thoughts? I'm happy to change the example to use like people have suggested above. nice usage example :+1:\nUh yea, that sounds fine to me. This behavior is definitely non-standard markdown but it's an example so not a big deal. We should probably do the same for the tutorial while we're here. And it's on cdnjs so that's all pretty easy:\nJust going to use marked instead, which I'm already familiar with and has an option to sanitize input.", "commid": "react_issue_3501", "tokennum": 304}], "negative_passages": []}
{"query_id": "q-en-react-2ecdf99ae0b477493332383441b1b8e37fd7275f72a0cb086c37af80dd52bf6b", "query": "const elementType = getElementTypeForFiber(fiber); const {_debugOwner} = fiber; <del> const ownerID = _debugOwner != null ? getFiberIDThrows(_debugOwner) : 0; </del> <ins> // Ideally we should call getFiberIDThrows() for _debugOwner, // since owners are almost always higher in the tree (and so have already been processed), // but in some (rare) instances reported in open source, a descendant mounts before an owner. // Since this is a DEV only field it's probably okay to also just lazily generate and ID here if needed. // See https://github.com/facebook/react/issues/21445 const ownerID = _debugOwner != null ? getOrGenerateFiberID(_debugOwner) : 0; </ins> const parentID = parentFiber ? getFiberIDThrows(parentFiber) : 0; const displayNameStringID = getStringID(displayName);", "positive_passages": [{"docid": "doc-en-react-5b14df309377a17bd5514bd579e6532180f9dee2acbfcb39a58bb5a33ba12481", "text": "<!-- Please answer both questions below before submitting this issue. --Please provide a link to the URL of the website (if it is public), a CodeSandbox () example that reproduces the bug, or a project on GitHub that we can checkout and run locally. If possible, please describe how to reproduce this bug on the website or app mentioned above: <!-- FILL THIS IN --<!-- FILL THIS IN --<!-- FILL THIS IN --<!---------------------------------------------------<!-- Please do not remove the text below this line --<!---------------------------------------------------DevTools version: 4.13.1- Call stack: at chrome- at (chrome-) at chrome- at listener (chrome-) Component stack: (none) GitHub URL search query:\nHi I'm sorry you ran into this problem Unfortunately, it doesn't look like this issue has enough info for one of us to reproduce it though. This means that it's going to be very hard for us to fix. Please help us by providing a link to a CodeSandbox (), a repository on GitHub, or a minimal code example that reproduces the problem. (Screenshots or videos can also be helpful if they help provide context on how to repro the bug.) Here are some tips for providing a minimal example:\nI am also having this bug\nSee the comment above please :) Repro is needed.\nThis happened to me, the node wasn't appearing in the Components tree and I was getting this error. The problem was that my attribute was way too long\n! suddenly having this issue right now. I thought it was because of my commits, but changing to another old branch just give the same errors. it was working just fine yesterday, don't know why. maybe due to the devtools update or something? btw I'm on react 16.8.6, react devtools 4.13.3 (5/19/2021)\nTry updating to the latest release (4.13.4) just to rule anything out. But if you're still seeing the issue, then we still need a repro case.\nat first the bug still persists. with same error log. then I retried close the devtools and opened it again (I think I actually have done this as well before) then somehow it works now. the error log still shows up but at least now all components are showing on the devtools, and that's all I need.", "commid": "react_issue_21445", "tokennum": 634}], "negative_passages": []}
{"query_id": "q-en-react-2ecdf99ae0b477493332383441b1b8e37fd7275f72a0cb086c37af80dd52bf6b", "query": "const elementType = getElementTypeForFiber(fiber); const {_debugOwner} = fiber; <del> const ownerID = _debugOwner != null ? getFiberIDThrows(_debugOwner) : 0; </del> <ins> // Ideally we should call getFiberIDThrows() for _debugOwner, // since owners are almost always higher in the tree (and so have already been processed), // but in some (rare) instances reported in open source, a descendant mounts before an owner. // Since this is a DEV only field it's probably okay to also just lazily generate and ID here if needed. // See https://github.com/facebook/react/issues/21445 const ownerID = _debugOwner != null ? getOrGenerateFiberID(_debugOwner) : 0; </ins> const parentID = parentFiber ? getFiberIDThrows(parentFiber) : 0; const displayNameStringID = getStringID(displayName);", "positive_passages": [{"docid": "doc-en-react-08b723364bc5c4576a513010a372c7287da5a14b18ef1da84116bda7cdd5b8b4", "text": "in addition, I found this ! and I was trying to hide that component (which has no recent changes on it) to see whether it has any impact. or any component that last showing on the devtools. but for now, that'll be all. thank you for responding\nI appreciate the extra information, but this isn't a description that I can use to reproduce (and fix) the bug. I need an actual website (or code) that I can run along with instructions (like \"do this, then this\") so I can see the bug.\nThere are some simple code could help reproduce. You could try following code sandbox link. The reproduce steps are: \"Do not\" open develop panel. to develop panel and go to react dev tab. Errors was shown. I guess it's kind of race condition. When I change the component order such as It will work perfect. Ps: brief explain what component do. The PageLoadProgressHandler will dispatch float element to PopupPool.\nExcellent! Thank you, Super interesting that this bug only occurs if you wait to open DevTools until after the page has loaded.\nI think it is because only have two components, I have two sites, one it will always happen, another will random happen. or maybe code-sandbox do some strange things.\nThis is interesting. The reason DevTools throws is that the Fiber's owner (the attribute) points to a Fiber that hasn't been mounted yet. That seems unexpected. This repro is just a wrapper around two NPM packages. Where's the source code for these packages? :D Edit I found it, although there's a lot of indirection here_. Tracing one package which imports another which imports another. Would be helpful if it were flattened but I guess I can always step through the bundled source.\nPopupPool: PageLoadProgressHandler: Good luck... XD.\nInterestingly, if I copy the , , and source files into the sandbox (and only change the import statement in ) the bug goes away. That's surprising.\nI wonder if I'm running slightly different code? The debug log shows a slightly different tree structure.", "commid": "react_issue_21445", "tokennum": 461}], "negative_passages": []}
{"query_id": "q-en-react-2ecdf99ae0b477493332383441b1b8e37fd7275f72a0cb086c37af80dd52bf6b", "query": "const elementType = getElementTypeForFiber(fiber); const {_debugOwner} = fiber; <del> const ownerID = _debugOwner != null ? getFiberIDThrows(_debugOwner) : 0; </del> <ins> // Ideally we should call getFiberIDThrows() for _debugOwner, // since owners are almost always higher in the tree (and so have already been processed), // but in some (rare) instances reported in open source, a descendant mounts before an owner. // Since this is a DEV only field it's probably okay to also just lazily generate and ID here if needed. // See https://github.com/facebook/react/issues/21445 const ownerID = _debugOwner != null ? getOrGenerateFiberID(_debugOwner) : 0; </ins> const parentID = parentFiber ? getFiberIDThrows(parentFiber) : 0; const displayNameStringID = getStringID(displayName);", "positive_passages": [{"docid": "doc-en-react-a2a4fb71d5d3b864e65637ebe9f2baaf476cc588c4fe7c6119965be14b4934d0", "text": "Is the version of the source you linked me to the same as the one the Sandbox points to in NPM, Edit Looks like the repro is using 0.18.8 (released a couple of months ago) but the latest NPM release is 0.11.1. That being said, it doesn't look like the files that are being imported have changed (at least not in source) so I'm still not sure what's up.\nI change two main components to hook style then get better performance, it reduce the error happen, but I still could get error. Some error is happen after component render done and open the panel same behavior with pervious. I'll log my changes in following issue ticket.\nWould be nice to get a smaller reproduction of this issue (all of the code in one project, rather than spread across many NPM packages). That's what I was trying to do with moving the source but then the bug goes away b'c the code seems to be different. I noticed one potential difference being the indirection but I'm not sure how likely that is to be related.\nLooking at the error while debugging, it looks like the , then either renders it or dispatches a popup event to show it. I'm not sure why (too sleepy to think it through maybe) but sometimes seems to be mounting before_ has, which goes against an assumption in DevTools. Will dig back in tomorrow.\nI really appreciate the repro case, but there are so many layers of indirection between the various NPM packages being used to dynamically create the components. It's difficult to trace through. I'm going to hand this issue to you and ask for a smaller repro case. (Without 10+ NPM projects that each require each other.) Is this something you can help with? Edit I fixed this () but the test case I is not great since it relies on unsupported side effects to trigger the problem case. I'd still love to get a smaller repro so I can (1) be sure I fully fixed the problem and (2) add a regression case so it doesn't get re-introduced.\nBugfix released as\nthank you fixed on version 4.13.5\nThanks your effort. Your fixed also be success from my side.", "commid": "react_issue_21445", "tokennum": 484}], "negative_passages": []}
{"query_id": "q-en-react-320fb007e8626bf23a4b5d9396e86f181bc8b6c98f43abd30ac69de3fc173817", "query": "<del> // // showdown.js -- A javascript port of Markdown. // // Copyright (c) 2007 John Fraser. // // Original Markdown Copyright (c) 2004-2005 John Gruber // <http://daringfireball.net/projects/markdown/> // // Redistributable under a BSD-style open source license. // See license.txt for more information. // // The full source distribution is at: // //\t\t\t\tA A L //\t\t\t\tT C A //\t\t\t\tT K B // // <http://www.attacklab.net/> // // // Wherever possible, Showdown is a straight, line-by-line port // of the Perl version of Markdown. // // This is not a normal parser design; it's basically just a // series of string substitutions. It's hard to read and // maintain this way, but keeping Showdown close to the original // design makes it easier to port new features. // // More importantly, Showdown behaves like markdown.pl in most // edge cases. So web applications can do client-side preview // in Javascript, and then build identical HTML on the server. // // This port needs the new RegExp functionality of ECMA 262, // 3rd Edition (i.e. Javascript 1.5). Most modern web browsers // should do fine. Even with the new regular expression features, // We do a lot of work to emulate Perl's regex functionality. // The tricky changes in this file mostly have the \"attacklab:\" // label. Major or self-explanatory changes don't. // // Smart diff tools like Araxis Merge will be able to match up // this file with markdown.pl in a useful way. A little tweaking // helps: in a copy of markdown.pl, replace \"#\" with \"//\" and // replace \"$text\" with \"text\". Be sure to ignore whitespace // and line endings. // // // Showdown usage: // // var text = \"Markdown *rocks*.\"; // // var converter = new Showdown.converter(); // var html = converter.makeHtml(text); // // alert(html); // // Note: move the sample code to the bottom of this // file before uncommenting it. // // // Showdown namespace // var Showdown = {}; // // converter // // Wraps all \"globals\" so that the only thing // exposed is makeHtml(). // Showdown.converter = function() { // // Globals: // // Global hashes, used by various utility routines var g_urls; var g_titles; var g_html_blocks; // Used to track when we're inside an ordered or unordered list // (see _ProcessListItems() for details): var g_list_level = 0; this.makeHtml = function(text) { // // Main function. The order in which other subs are called here is // essential. Link and image substitutions need to happen before // _EscapeSpecialCharsWithinTagAttributes(), so that any *'s or _'s in the <a> // and <img> tags get encoded. // // Clear the global hashes. If we don't clear these, you get conflicts // from other articles when generating a page which contains more than // one article (e.g. an index page that shows the N most recent // articles): g_urls = new Array(); g_titles = new Array(); g_html_blocks = new Array(); // attacklab: Replace ~ with ~T // This lets us use tilde as an escape char to avoid md5 hashes // The choice of character is arbitray; anything that isn't // magic in Markdown will work. text = text.replace(/~/g,\"~T\"); // attacklab: Replace $ with ~D // RegExp interprets $ as a special character // when it's in a replacement string text = text.replace(/$/g,\"~D\"); // Standardize line endings text = text.replace(/rn/g,\"n\"); // DOS to Unix text = text.replace(/r/g,\"n\"); // Mac to Unix // Make sure text begins and ends with a couple of newlines: text = \"nn\" + text + \"nn\"; // Convert all tabs to spaces. text = _Detab(text); // Strip any lines consisting only of spaces and tabs. // This makes subsequent regexen easier to write, because we can // match consecutive blank lines with /n+/ instead of something // contorted like /[ t]*n+/ . text = text.replace(/^[ t]+$/mg,\"\"); // Turn block-level HTML blocks into hash entries text = _HashHTMLBlocks(text); // Strip link definitions, store in hashes. text = _StripLinkDefinitions(text); text = _RunBlockGamut(text); text = _UnescapeSpecialChars(text); // attacklab: Restore dollar signs text = text.replace(/~D/g,\"$$\"); // attacklab: Restore tildes text = text.replace(/~T/g,\"~\"); return text; } var _StripLinkDefinitions = function(text) { // // Strips link definitions from text, stores the URLs and titles in // hash references. // // Link defs are in the form: ^[id]: url \"optional title\" /* var text = text.replace(/ ^[ ]{0,3}[(.+)]: // id = $1 attacklab: g_tab_width - 1 [ t]* n?\t\t\t\t// maybe *one* newline [ t]* <?(S+?)>?\t\t\t// url = $2 [ t]* n?\t\t\t\t// maybe one newline [ t]* (?: (n*)\t\t\t\t// any lines skipped = $3 attacklab: lookbehind removed [\"(] (.+?)\t\t\t\t// title = $4 [\")] [ t]* )?\t\t\t\t\t// title is optional (?:n+|$) /gm, function(){...}); */ var text = text.replace(/^[ ]{0,3}[(.+)]:[ t]*n?[ t]*<?(S+?)>?[ t]*n?[ t]*(?:(n*)[\"(](.+?)[\")][ t]*)?(?:n+|Z)/gm, function (wholeMatch,m1,m2,m3,m4) { m1 = m1.toLowerCase(); g_urls[m1] = _EncodeAmpsAndAngles(m2); // Link IDs are case-insensitive if (m3) { // Oops, found blank lines, so it's not a title. // Put back the parenthetical statement we stole. return m3+m4; } else if (m4) { g_titles[m1] = m4.replace(/\"/g,\"&quot;\"); } // Completely remove the definition from the text return \"\"; } ); return text; } var _HashHTMLBlocks = function(text) { // attacklab: Double up blank lines to reduce lookaround text = text.replace(/n/g,\"nn\"); // Hashify HTML blocks: // We only want to do this for block-level HTML tags, such as headers, // lists, and tables. That's because we still want to wrap <p>s around // \"paragraphs\" that are wrapped in non-block-level tags, such as anchors, // phrase emphasis, and spans. The list of tags we're looking for is // hard-coded: var block_tags_a = \"p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del\" var block_tags_b = \"p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math\" // First, look for nested blocks, e.g.: // <div> // <div> // tags for inner block must be indented. // </div> // </div> // // The outermost tags must start at the left margin for this to match, and // the inner nested divs must be indented. // We need to do this before the next, more liberal match, because the next // match will start at the first `<div>` and stop at the first `</div>`. // attacklab: This regex can be expensive when it fails. /* var text = text.replace(/ (\t\t\t\t\t\t// save in $1 ^\t\t\t\t\t// start of line (with /m) <($block_tags_a)\t// start tag = $2 b\t\t\t\t\t// word break // attacklab: hack around khtml/pcre bug... [^r]*?n\t\t\t// any number of lines, minimally matching </2>\t\t\t\t// the matching end tag [ t]*\t\t\t\t// trailing spaces/tabs (?=n+)\t\t\t\t// followed by a newline )\t\t\t\t\t\t// attacklab: there are sentinel newlines at end of document /gm,function(){...}}; */ text = text.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del)b[^r]*?n</2>[ t]*(?=n+))/gm,hashElement); // // Now match more liberally, simply from `n<tag>` to `</tag>n` // /* var text = text.replace(/ (\t\t\t\t\t\t// save in $1 ^\t\t\t\t\t// start of line (with /m) <($block_tags_b)\t// start tag = $2 b\t\t\t\t\t// word break // attacklab: hack around khtml/pcre bug... [^r]*?\t\t\t\t// any number of lines, minimally matching .*</2>\t\t\t\t// the matching end tag [ t]*\t\t\t\t// trailing spaces/tabs (?=n+)\t\t\t\t// followed by a newline )\t\t\t\t\t\t// attacklab: there are sentinel newlines at end of document /gm,function(){...}}; */ text = text.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math)b[^r]*?.*</2>[ t]*(?=n+)n)/gm,hashElement); // Special case just for <hr />. It was easier to make a special case than // to make the other regex more complicated. /* text = text.replace(/ (\t\t\t\t\t\t// save in $1 nn\t\t\t\t// Starting after a blank line [ ]{0,3} (<(hr)\t\t\t\t// start tag = $2 b\t\t\t\t\t// word break ([^<>])*?\t\t\t// /?>)\t\t\t\t// the matching end tag [ t]* (?=n{2,})\t\t\t// followed by a blank line ) /g,hashElement); */ text = text.replace(/(n[ ]{0,3}(<(hr)b([^<>])*?/?>)[ t]*(?=n{2,}))/g,hashElement); // Special case for standalone HTML comments: /* text = text.replace(/ (\t\t\t\t\t\t// save in $1 nn\t\t\t\t// Starting after a blank line [ ]{0,3}\t\t\t// attacklab: g_tab_width - 1 <! (--[^r]*?--s*)+ > [ t]* (?=n{2,})\t\t\t// followed by a blank line ) /g,hashElement); */ text = text.replace(/(nn[ ]{0,3}<!(--[^r]*?--s*)+>[ t]*(?=n{2,}))/g,hashElement); // PHP and ASP-style processor instructions (<?...?> and <%...%>) /* text = text.replace(/ (?: nn\t\t\t\t// Starting after a blank line ) (\t\t\t\t\t\t// save in $1 [ ]{0,3}\t\t\t// attacklab: g_tab_width - 1 (?: <([?%])\t\t\t// $2 [^r]*? 2> ) [ t]* (?=n{2,})\t\t\t// followed by a blank line ) /g,hashElement); */ text = text.replace(/(?:nn)([ ]{0,3}(?:<([?%])[^r]*?2>)[ t]*(?=n{2,}))/g,hashElement); // attacklab: Undo double lines (see comment at top of this function) text = text.replace(/nn/g,\"n\"); return text; } var hashElement = function(wholeMatch,m1) { var blockText = m1; // Undo double lines blockText = blockText.replace(/nn/g,\"n\"); blockText = blockText.replace(/^n/,\"\"); // strip trailing blank lines blockText = blockText.replace(/n+$/g,\"\"); // Replace the element text with a marker (\"~KxK\" where x is its key) blockText = \"nn~K\" + (g_html_blocks.push(blockText)-1) + \"Knn\"; return blockText; }; var _RunBlockGamut = function(text) { // // These are all the transformations that form block-level // tags like paragraphs, headers, and list items. // text = _DoHeaders(text); // Do Horizontal Rules: var key = hashBlock(\"<hr />\"); text = text.replace(/^[ ]{0,2}([ ]?*[ ]?){3,}[ t]*$/gm,key); text = text.replace(/^[ ]{0,2}([ ]?-[ ]?){3,}[ t]*$/gm,key); text = text.replace(/^[ ]{0,2}([ ]?_[ ]?){3,}[ t]*$/gm,key); text = _DoLists(text); text = _DoCodeBlocks(text); text = _DoBlockQuotes(text); // We already ran _HashHTMLBlocks() before, in Markdown(), but that // was to escape raw HTML in the original Markdown source. This time, // we're escaping the markup we've just created, so that we don't wrap // <p> tags around block-level tags. text = _HashHTMLBlocks(text); text = _FormParagraphs(text); return text; } var _RunSpanGamut = function(text) { // // These are all the transformations that occur *within* block-level // tags like paragraphs, headers, and list items. // text = _DoCodeSpans(text); text = _EscapeSpecialCharsWithinTagAttributes(text); text = _EncodeBackslashEscapes(text); // Process anchor and image tags. Images must come first, // because ![foo][f] looks like an anchor. text = _DoImages(text); text = _DoAnchors(text); // Make links out of things like `<http://example.com/>` // Must come after _DoAnchors(), because you can use < and > // delimiters in inline links like [this](<url>). text = _DoAutoLinks(text); text = _EncodeAmpsAndAngles(text); text = _DoItalicsAndBold(text); // Do hard breaks: text = text.replace(/ +n/g,\" <br />n\"); return text; } var _EscapeSpecialCharsWithinTagAttributes = function(text) { // // Within tags -- meaning between < and > -- encode [ ` * _] so they // don't conflict with their use in Markdown for code, italics and strong. // // Build a regex to find HTML tags and comments. See Friedl's // \"Mastering Regular Expressions\", 2nd Ed., pp. 200-201. var regex = /(<[a-z/!$](\"[^\"]*\"|'[^']*'|[^'\">])*>|<!(--.*?--s*)+>)/gi; text = text.replace(regex, function(wholeMatch) { var tag = wholeMatch.replace(/(.)</?code>(?=.)/g,\"$1`\"); tag = escapeCharacters(tag,\"`*_\"); return tag; }); return text; } var _DoAnchors = function(text) { // // Turn Markdown link shortcuts into XHTML <a> tags. // // // First, handle reference-style links: [link text] [id] // /* text = text.replace(/ (\t\t\t\t\t\t\t// wrap whole match in $1 [ ( (?: [[^]]*]\t\t// allow brackets nested one level | [^[]\t\t\t// or anything else )* ) ] [ ]?\t\t\t\t\t// one optional space (?:n[ ]*)?\t\t\t\t// one optional newline followed by spaces [ (.*?)\t\t\t\t\t// id = $3 ] )()()()()\t\t\t\t\t// pad remaining backreferences /g,_DoAnchors_callback); */ text = text.replace(/([((?:[[^]]*]|[^[]])*)][ ]?(?:n[ ]*)?[(.*?)])()()()()/g,writeAnchorTag); // // Next, inline-style links: [link text](url \"optional title\") // /* text = text.replace(/ (\t\t\t\t\t\t// wrap whole match in $1 [ ( (?: [[^]]*]\t// allow brackets nested one level | [^[]]\t\t\t// or anything else ) ) ] (\t\t\t\t\t\t// literal paren [ t]* ()\t\t\t\t\t\t// no id, so leave $3 empty <?(.*?)>?\t\t\t\t// href = $4 [ t]* (\t\t\t\t\t\t// $5 (['\"])\t\t\t\t// quote char = $6 (.*?)\t\t\t\t// Title = $7 6\t\t\t\t\t// matching quote [ t]*\t\t\t\t// ignore any spaces/tabs between closing quote and ) )?\t\t\t\t\t\t// title is optional ) ) /g,writeAnchorTag); */ text = text.replace(/([((?:[[^]]*]|[^[]])*)]([ t]*()<?(.*?)>?[ t]*((['\"])(.*?)6[ t]*)?))/g,writeAnchorTag); // // Last, handle reference-style shortcuts: [link text] // These must come last in case you've also got [link test][1] // or [link test](/foo) // /* text = text.replace(/ (\t\t \t\t\t\t\t// wrap whole match in $1 [ ([^[]]+)\t\t\t\t// link text = $2; can't contain '[' or ']' ] )()()()()()\t\t\t\t\t// pad rest of backreferences /g, writeAnchorTag); */ text = text.replace(/([([^[]]+)])()()()()()/g, writeAnchorTag); return text; } var writeAnchorTag = function(wholeMatch,m1,m2,m3,m4,m5,m6,m7) { if (m7 == undefined) m7 = \"\"; var whole_match = m1; var link_text = m2; var link_id\t = m3.toLowerCase(); var url\t\t= m4; var title\t= m7; if (url == \"\") { if (link_id == \"\") { // lower-case and turn embedded newlines into spaces link_id = link_text.toLowerCase().replace(/ ?n/g,\" \"); } url = \"#\"+link_id; if (g_urls[link_id] != undefined) { url = g_urls[link_id]; if (g_titles[link_id] != undefined) { title = g_titles[link_id]; } } else { if (whole_match.search(/(s*)$/m)>-1) { // Special case for explicit empty url url = \"\"; } else { return whole_match; } } } url = escapeCharacters(url,\"*_\"); var result = \"<a href=\"\" + url + \"\"\"; if (title != \"\") { title = title.replace(/\"/g,\"&quot;\"); title = escapeCharacters(title,\"*_\"); result += \" title=\"\" + title + \"\"\"; } result += \">\" + link_text + \"</a>\"; return result; } var _DoImages = function(text) { // // Turn Markdown image shortcuts into <img> tags. // // // First, handle reference-style labeled images: ![alt text][id] // /* text = text.replace(/ (\t\t\t\t\t\t// wrap whole match in $1 ![ (.*?)\t\t\t\t// alt text = $2 ] [ ]?\t\t\t\t// one optional space (?:n[ ]*)?\t\t\t// one optional newline followed by spaces [ (.*?)\t\t\t\t// id = $3 ] )()()()()\t\t\t\t// pad rest of backreferences /g,writeImageTag); */ text = text.replace(/(![(.*?)][ ]?(?:n[ ]*)?[(.*?)])()()()()/g,writeImageTag); // // Next, handle inline images: ![alt text](url \"optional title\") // Don't forget: encode * and _ /* text = text.replace(/ (\t\t\t\t\t\t// wrap whole match in $1 ![ (.*?)\t\t\t\t// alt text = $2 ] s?\t\t\t\t\t// One optional whitespace character (\t\t\t\t\t// literal paren [ t]* ()\t\t\t\t\t// no id, so leave $3 empty <?(S+?)>?\t\t\t// src url = $4 [ t]* (\t\t\t\t\t// $5 (['\"])\t\t\t// quote char = $6 (.*?)\t\t\t// title = $7 6\t\t\t\t// matching quote [ t]* )?\t\t\t\t\t// title is optional ) ) /g,writeImageTag); */ text = text.replace(/(![(.*?)]s?([ t]*()<?(S+?)>?[ t]*((['\"])(.*?)6[ t]*)?))/g,writeImageTag); return text; } var writeImageTag = function(wholeMatch,m1,m2,m3,m4,m5,m6,m7) { var whole_match = m1; var alt_text = m2; var link_id\t = m3.toLowerCase(); var url\t\t= m4; var title\t= m7; if (!title) title = \"\"; if (url == \"\") { if (link_id == \"\") { // lower-case and turn embedded newlines into spaces link_id = alt_text.toLowerCase().replace(/ ?n/g,\" \"); } url = \"#\"+link_id; if (g_urls[link_id] != undefined) { url = g_urls[link_id]; if (g_titles[link_id] != undefined) { title = g_titles[link_id]; } } else { return whole_match; } } alt_text = alt_text.replace(/\"/g,\"&quot;\"); url = escapeCharacters(url,\"*_\"); var result = \"<img src=\"\" + url + \"\" alt=\"\" + alt_text + \"\"\"; // attacklab: Markdown.pl adds empty title attributes to images. // Replicate this bug. //if (title != \"\") { title = title.replace(/\"/g,\"&quot;\"); title = escapeCharacters(title,\"*_\"); result += \" title=\"\" + title + \"\"\"; //} result += \" />\"; return result; } var _DoHeaders = function(text) { // Setext-style headers: //\tHeader 1 //\t======== // //\tHeader 2 //\t-------- // text = text.replace(/^(.+)[ t]*n=+[ t]*n+/gm, function(wholeMatch,m1){return hashBlock('<h1 id=\"' + headerId(m1) + '\">' + _RunSpanGamut(m1) + \"</h1>\");}); text = text.replace(/^(.+)[ t]*n-+[ t]*n+/gm, function(matchFound,m1){return hashBlock('<h2 id=\"' + headerId(m1) + '\">' + _RunSpanGamut(m1) + \"</h2>\");}); // atx-style headers: // # Header 1 // ## Header 2 // ## Header 2 with closing hashes ## // ... // ###### Header 6 // /* text = text.replace(/ ^(#{1,6})\t\t\t\t// $1 = string of #'s [ t]* (.+?)\t\t\t\t\t// $2 = Header text [ t]* #*\t\t\t\t\t\t// optional closing #'s (not counted) n+ /gm, function() {...}); */ text = text.replace(/^(#{1,6})[ t]*(.+?)[ t]*#*n+/gm, function(wholeMatch,m1,m2) { var h_level = m1.length; return hashBlock(\"<h\" + h_level + ' id=\"' + headerId(m2) + '\">' + _RunSpanGamut(m2) + \"</h\" + h_level + \">\"); }); function headerId(m) { return m.replace(/[^w]/g, '').toLowerCase(); } return text; } // This declaration keeps Dojo compressor from outputting garbage: var _ProcessListItems; var _DoLists = function(text) { // // Form HTML ordered (numbered) and unordered (bulleted) lists. // // attacklab: add sentinel to hack around khtml/safari bug: // http://bugs.webkit.org/show_bug.cgi?id=11231 text += \"~0\"; // Re-usable pattern to match any entirel ul or ol list: /* var whole_list = / (\t\t\t\t\t\t\t\t\t// $1 = whole list (\t\t\t\t\t\t\t\t// $2 [ ]{0,3}\t\t\t\t\t// attacklab: g_tab_width - 1 ([*+-]|d+[.])\t\t\t\t// $3 = first list item marker [ t]+ ) [^r]+? (\t\t\t\t\t\t\t\t// $4 ~0\t\t\t\t\t\t\t// sentinel for workaround; should be $ | n{2,} (?=S) (?!\t\t\t\t\t\t\t// Negative lookahead for another list item marker [ t]* (?:[*+-]|d+[.])[ t]+ ) ) )/g */ var whole_list = /^(([ ]{0,3}([*+-]|d+[.])[ t]+)[^r]+?(~0|n{2,}(?=S)(?![ t]*(?:[*+-]|d+[.])[ t]+)))/gm; if (g_list_level) { text = text.replace(whole_list,function(wholeMatch,m1,m2) { var list = m1; var list_type = (m2.search(/[*+-]/g)>-1) ? \"ul\" : \"ol\"; // Turn double returns into triple returns, so that we can make a // paragraph for the last item in a list, if necessary: list = list.replace(/n{2,}/g,\"nnn\");; var result = _ProcessListItems(list); // Trim any trailing whitespace, to put the closing `</$list_type>` // up on the preceding line, to get it past the current stupid // HTML block parser. This is a hack to work around the terrible // hack that is the HTML block parser. result = result.replace(/s+$/,\"\"); result = \"<\"+list_type+\">\" + result + \"</\"+list_type+\">n\"; return result; }); } else { whole_list = /(nn|^n?)(([ ]{0,3}([*+-]|d+[.])[ t]+)[^r]+?(~0|n{2,}(?=S)(?![ t]*(?:[*+-]|d+[.])[ t]+)))/g; text = text.replace(whole_list,function(wholeMatch,m1,m2,m3) { var runup = m1; var list = m2; var list_type = (m3.search(/[*+-]/g)>-1) ? \"ul\" : \"ol\"; // Turn double returns into triple returns, so that we can make a // paragraph for the last item in a list, if necessary: var list = list.replace(/n{2,}/g,\"nnn\");; var result = _ProcessListItems(list); result = runup + \"<\"+list_type+\">n\" + result + \"</\"+list_type+\">n\"; return result; }); } // attacklab: strip sentinel text = text.replace(/~0/,\"\"); return text; } _ProcessListItems = function(list_str) { // // Process the contents of a single ordered or unordered list, splitting it // into individual list items. // // The $g_list_level global keeps track of when we're inside a list. // Each time we enter a list, we increment it; when we leave a list, // we decrement. If it's zero, we're not in a list anymore. // // We do this because when we're not inside a list, we want to treat // something like this: // // I recommend upgrading to version // 8. Oops, now this line is treated // as a sub-list. // // As a single paragraph, despite the fact that the second line starts // with a digit-period-space sequence. // // Whereas when we're inside a list (or sub-list), that line will be // treated as the start of a sub-list. What a kludge, huh? This is // an aspect of Markdown's syntax that's hard to parse perfectly // without resorting to mind-reading. Perhaps the solution is to // change the syntax rules such that sub-lists must start with a // starting cardinal number; e.g. \"1.\" or \"a.\". g_list_level++; // trim trailing blank lines: list_str = list_str.replace(/n{2,}$/,\"n\"); // attacklab: add sentinel to emulate z list_str += \"~0\"; /* list_str = list_str.replace(/ (n)?\t\t\t\t\t\t\t// leading line = $1 (^[ t]*)\t\t\t\t\t\t// leading whitespace = $2 ([*+-]|d+[.]) [ t]+\t\t\t// list marker = $3 ([^r]+?\t\t\t\t\t\t// list item text = $4 (n{1,2})) (?= n* (~0 | 2 ([*+-]|d+[.]) [ t]+)) /gm, function(){...}); */ list_str = list_str.replace(/(n)?(^[ t]*)([*+-]|d+[.])[ t]+([^r]+?(n{1,2}))(?=n*(~0|2([*+-]|d+[.])[ t]+))/gm, function(wholeMatch,m1,m2,m3,m4){ var item = m4; var leading_line = m1; var leading_space = m2; if (leading_line || (item.search(/n{2,}/)>-1)) { item = _RunBlockGamut(_Outdent(item)); } else { // Recursion for sub-lists: item = _DoLists(_Outdent(item)); item = item.replace(/n$/,\"\"); // chomp(item) item = _RunSpanGamut(item); } return \"<li>\" + item + \"</li>n\"; } ); // attacklab: strip sentinel list_str = list_str.replace(/~0/g,\"\"); g_list_level--; return list_str; } var _DoCodeBlocks = function(text) { // // Process Markdown `<pre><code>` blocks. // /* text = text.replace(text, /(?:nn|^) (\t\t\t\t\t\t\t\t// $1 = the code block -- one or more lines, starting with a space/tab (?: (?:[ ]{4}|t)\t\t\t// Lines must start with a tab or a tab-width of spaces - attacklab: g_tab_width .*n+ )+ ) (n*[ ]{0,3}[^ tn]|(?=~0))\t// attacklab: g_tab_width /g,function(){...}); */ // attacklab: sentinel workarounds for lack of A and Z, safarikhtml bug text += \"~0\"; text = text.replace(/(?:nn|^)((?:(?:[ ]{4}|t).*n+)+)(n*[ ]{0,3}[^ tn]|(?=~0))/g, function(wholeMatch,m1,m2) { var codeblock = m1; var nextChar = m2; codeblock = _EncodeCode( _Outdent(codeblock)); codeblock = _Detab(codeblock); codeblock = codeblock.replace(/^n+/g,\"\"); // trim leading newlines codeblock = codeblock.replace(/n+$/g,\"\"); // trim trailing whitespace codeblock = \"<pre><code>\" + codeblock + \"n</code></pre>\"; return hashBlock(codeblock) + nextChar; } ); // attacklab: strip sentinel text = text.replace(/~0/,\"\"); return text; } var hashBlock = function(text) { text = text.replace(/(^n+|n+$)/g,\"\"); return \"nn~K\" + (g_html_blocks.push(text)-1) + \"Knn\"; } var _DoCodeSpans = function(text) { // // * Backtick quotes are used for <code></code> spans. // // * You can use multiple backticks as the delimiters if you want to //\t include literal backticks in the code span. So, this input: // //\t\t Just type ``foo `bar` baz`` at the prompt. // //\t Will translate to: // //\t\t <p>Just type <code>foo `bar` baz</code> at the prompt.</p> // //\tThere's no arbitrary limit to the number of backticks you //\tcan use as delimters. If you need three consecutive backticks //\tin your code, use four for delimiters, etc. // // * You can use spaces to get literal backticks at the edges: // //\t\t ... type `` `bar` `` ... // //\t Turns to: // //\t\t ... type <code>`bar`</code> ... // /* text = text.replace(/ (^|[^])\t\t\t\t\t// Character before opening ` can't be a backslash (`+)\t\t\t\t\t\t// $2 = Opening run of ` (\t\t\t\t\t\t\t// $3 = The code block [^r]*? [^`]\t\t\t\t\t// attacklab: work around lack of lookbehind ) 2\t\t\t\t\t\t\t// Matching closer (?!`) /gm, function(){...}); */ text = text.replace(/(^|[^])(`+)([^r]*?[^`])2(?!`)/gm, function(wholeMatch,m1,m2,m3,m4) { var c = m3; c = c.replace(/^([ t]*)/g,\"\");\t// leading whitespace c = c.replace(/[ t]*$/g,\"\");\t// trailing whitespace c = _EncodeCode(c); return m1+\"<code>\"+c+\"</code>\"; }); return text; } var _EncodeCode = function(text) { // // Encode/escape certain characters inside Markdown code runs. // The point is that in code, these characters are literals, // and lose their special Markdown meanings. // // Encode all ampersands; HTML entities are not // entities within a Markdown code span. text = text.replace(/&/g,\"&amp;\"); // Do the angle bracket song and dance: text = text.replace(/</g,\"&lt;\"); text = text.replace(/>/g,\"&gt;\"); // Now, escape characters that are magic in Markdown: text = escapeCharacters(text,\"*_{}[]\",false); // jj the line above breaks this: //--- //* Item // 1. Subitem // special char: * //--- return text; } var _DoItalicsAndBold = function(text) { // <strong> must go first: text = text.replace(/(**|__)(?=S)([^r]*?S[*_]*)1/g, \"<strong>$2</strong>\"); text = text.replace(/(*|_)(?=S)([^r]*?S)1/g, \"<em>$2</em>\"); return text; } var _DoBlockQuotes = function(text) { /* text = text.replace(/ (\t\t\t\t\t\t\t\t// Wrap whole match in $1 ( ^[ t]*>[ t]?\t\t\t// '>' at the start of a line .+n\t\t\t\t\t// rest of the first line (.+n)*\t\t\t\t\t// subsequent consecutive lines n*\t\t\t\t\t\t// blanks )+ ) /gm, function(){...}); */ text = text.replace(/((^[ t]*>[ t]?.+n(.+n)*n*)+)/gm, function(wholeMatch,m1) { var bq = m1; // attacklab: hack around Konqueror 3.5.4 bug: // \"----------bug\".replace(/^-/g,\"\") == \"bug\" bq = bq.replace(/^[ t]*>[ t]?/gm,\"~0\");\t// trim one level of quoting // attacklab: clean up hack bq = bq.replace(/~0/g,\"\"); bq = bq.replace(/^[ t]+$/gm,\"\");\t\t// trim whitespace-only lines bq = _RunBlockGamut(bq);\t\t\t\t// recurse bq = bq.replace(/(^|n)/g,\"$1 \"); // These leading spaces screw with <pre> content, so we need to fix that: bq = bq.replace( /(s*<pre>[^r]+?</pre>)/gm, function(wholeMatch,m1) { var pre = m1; // attacklab: hack around Konqueror 3.5.4 bug: pre = pre.replace(/^ /mg,\"~0\"); pre = pre.replace(/~0/g,\"\"); return pre; }); return hashBlock(\"<blockquote>n\" + bq + \"n</blockquote>\"); }); return text; } var _FormParagraphs = function(text) { // // Params: // $text - string to process with html <p> tags // // Strip leading and trailing lines: text = text.replace(/^n+/g,\"\"); text = text.replace(/n+$/g,\"\"); var grafs = text.split(/n{2,}/g); var grafsOut = new Array(); // // Wrap <p> tags. // var end = grafs.length; for (var i=0; i<end; i++) { var str = grafs[i]; // if this is an HTML marker, copy it if (str.search(/~K(d+)K/g) >= 0) { grafsOut.push(str); } else if (str.search(/S/) >= 0) { str = _RunSpanGamut(str); str = str.replace(/^([ t]*)/g,\"<p>\"); str += \"</p>\" grafsOut.push(str); } } // // Unhashify HTML blocks // end = grafsOut.length; for (var i=0; i<end; i++) { // if this is a marker for an html block... while (grafsOut[i].search(/~K(d+)K/) >= 0) { var blockText = g_html_blocks[RegExp.$1]; blockText = blockText.replace(/$/g,\"$$$$\"); // Escape any dollar signs grafsOut[i] = grafsOut[i].replace(/~Kd+K/,blockText); } } return grafsOut.join(\"nn\"); } var _EncodeAmpsAndAngles = function(text) { // Smart processing for ampersands and angle brackets that need to be encoded. // Ampersand-encoding based entirely on Nat Irons's Amputator MT plugin: // http://bumppo.net/projects/amputator/ text = text.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|w+);)/g,\"&amp;\"); // Encode naked <'s text = text.replace(/<(?![a-z/?$!])/gi,\"&lt;\"); return text; } var _EncodeBackslashEscapes = function(text) { // // Parameter: String. // Returns:\tThe string, with after processing the following backslash //\t\t\t escape sequences. // // attacklab: The polite way to do this is with the new // escapeCharacters() function: // // \ttext = escapeCharacters(text,\"\",true); // \ttext = escapeCharacters(text,\"`*_{}[]()>#+-.!\",true); // // ...but we're sidestepping its use of the (slow) RegExp constructor // as an optimization for Firefox. This function gets called a LOT. text = text.replace(/()/g,escapeCharacters_callback); text = text.replace(/([`*_{}[]()>#+-.!])/g,escapeCharacters_callback); return text; } var _DoAutoLinks = function(text) { text = text.replace(/<((https?|ftp|dict):[^'\">s]+)>/gi,\"<a href=\"$1\">$1</a>\"); // Email addresses: <address@domain.foo> /* text = text.replace(/ < (?:mailto:)? ( [-.w]+ @ [-a-z0-9]+(.[-a-z0-9]+)*.[a-z]+ ) > /gi, _DoAutoLinks_callback()); */ text = text.replace(/<(?:mailto:)?([-.w]+@[-a-z0-9]+(.[-a-z0-9]+)*.[a-z]+)>/gi, function(wholeMatch,m1) { return _EncodeEmailAddress( _UnescapeSpecialChars(m1) ); } ); return text; } var _EncodeEmailAddress = function(addr) { // // Input: an email address, e.g. \"foo@example.com\" // // Output: the email address as a mailto link, with each character //\tof the address encoded as either a decimal or hex entity, in //\tthe hopes of foiling most address harvesting spam bots. E.g.: // //\t<a href=\"&#x6D;&#97;&#105;&#108;&#x74;&#111;:&#102;&#111;&#111;&#64;&#101; //\t x&#x61;&#109;&#x70;&#108;&#x65;&#x2E;&#99;&#111;&#109;\">&#102;&#111;&#111; //\t &#64;&#101;x&#x61;&#109;&#x70;&#108;&#x65;&#x2E;&#99;&#111;&#109;</a> // // Based on a filter by Matthew Wickline, posted to the BBEdit-Talk // mailing list: <http://tinyurl.com/yu7ue> // // attacklab: why can't javascript speak hex? function char2hex(ch) { var hexDigits = '0123456789ABCDEF'; var dec = ch.charCodeAt(0); return(hexDigits.charAt(dec>>4) + hexDigits.charAt(dec&15)); } var encode = [ function(ch){return \"&#\"+ch.charCodeAt(0)+\";\";}, function(ch){return \"&#x\"+char2hex(ch)+\";\";}, function(ch){return ch;} ]; addr = \"mailto:\" + addr; addr = addr.replace(/./g, function(ch) { if (ch == \"@\") { // this *must* be encoded. I insist. ch = encode[Math.floor(Math.random()*2)](ch); } else if (ch !=\":\") { // leave ':' alone (to spot mailto: later) var r = Math.random(); // roughly 10% raw, 45% hex, 45% dec ch = ( r > .9 ?\tencode[2](ch) : r > .45 ?\tencode[1](ch) : encode[0](ch) ); } return ch; }); addr = \"<a href=\"\" + addr + \"\">\" + addr + \"</a>\"; addr = addr.replace(/\">.+:/g,\"\">\"); // strip the mailto: from the visible part return addr; } var _UnescapeSpecialChars = function(text) { // // Swap back in all the special characters we've hidden. // text = text.replace(/~E(d+)E/g, function(wholeMatch,m1) { var charCodeToReplace = parseInt(m1); return String.fromCharCode(charCodeToReplace); } ); return text; } var _Outdent = function(text) { // // Remove one level of line-leading tabs or spaces // // attacklab: hack around Konqueror 3.5.4 bug: // \"----------bug\".replace(/^-/g,\"\") == \"bug\" text = text.replace(/^(t|[ ]{1,4})/gm,\"~0\"); // attacklab: g_tab_width // attacklab: clean up hack text = text.replace(/~0/g,\"\") return text; } var _Detab = function(text) { // attacklab: Detab's completely rewritten for speed. // In perl we could fix it by anchoring the regexp with G. // In javascript we're less fortunate. // expand first n-1 tabs text = text.replace(/t(?=t)/g,\" \"); // attacklab: g_tab_width // replace the nth with two sentinels text = text.replace(/t/g,\"~A~B\"); // use the sentinel to anchor our regex so it doesn't explode text = text.replace(/~B(.+?)~A/g, function(wholeMatch,m1,m2) { var leadingText = m1; var numSpaces = 4 - leadingText.length % 4; // attacklab: g_tab_width // there *must* be a better way to do this: for (var i=0; i<numSpaces; i++) leadingText+=\" \"; return leadingText; } ); // clean up sentinels text = text.replace(/~A/g,\" \"); // attacklab: g_tab_width text = text.replace(/~B/g,\"\"); return text; } // // attacklab: Utility functions // var escapeCharacters = function(text, charsToEscape, afterBackslash) { // First we have to escape the escape characters so that // we can build a character class out of them var regexString = \"([\" + charsToEscape.replace(/([[]])/g,\"$1\") + \"])\"; if (afterBackslash) { regexString = \"\" + regexString; } var regex = new RegExp(regexString,\"g\"); text = text.replace(regex,escapeCharacters_callback); return text; } var escapeCharacters_callback = function(wholeMatch,m1) { var charCodeToEscape = m1.charCodeAt(0); return \"~E\"+charCodeToEscape+\"E\"; } } // end of Showdown.converter // export if (typeof exports != 'undefined') exports.Showdown = Showdown; </del> No newline at end of file", "positive_passages": [{"docid": "doc-en-react-bda68aba5b773f0e231d8ae9f598c5dea11ff75961a86d42353566558f7ff8f7", "text": "Since copy+pasting our code makes it too easy for people to XSS themselves, lets just add a comment in there about it.\nPR at - let me know if that's what you had in mind!\nMy intuition is that it makes more sense to fix the example (call a sanitization library) or to change the example completely (demonstrate something else that is safer). It looks really bad to have a security warning on the homepage of the react site. Makes it seem like our framework encourages unsafe operations, rather than a safe-by-default way of doing things.\nShould switch the demo to use a different library like markdown-js that escapes everything and doesn't support HTML:\nmarkdown-js looks good. First attempt: ,output Code licensed if someone wants to turn this into a coherent example; I've signed the CLA.\nThat's a good suggestion too :) - what are your thoughts? I'm happy to change the example to use like people have suggested above. nice usage example :+1:\nUh yea, that sounds fine to me. This behavior is definitely non-standard markdown but it's an example so not a big deal. We should probably do the same for the tutorial while we're here. And it's on cdnjs so that's all pretty easy:\nJust going to use marked instead, which I'm already familiar with and has an option to sanitize input.", "commid": "react_issue_3501", "tokennum": 304}], "negative_passages": []}
{"query_id": "q-en-react-32b235cb6e8ba8d86644eb19024c3bc27f3de5fd6bb953a2d7eb8cbdfb7b6b96", "query": ": emptyObject; const instance = new ctor(props, context); adoptClassInstance(workInProgress, instance); <del> checkClassInstance(workInProgress); </del> // Cache unmasked context so we can avoid recreating masked context unless necessary. // ReactFiberContext usually updates this cache but can't for newly-created instances.", "positive_passages": [{"docid": "doc-en-react-a67bb8376120b6e82f0ec7816daa64a33d39d6f140cc4daae8de19fe914fffd1", "text": "Follow up from Here's one I found. These two invariants: are in a function that's behind a DEV block: I don't think this is intentional, but need to verify. There may be more. I'll use this issue to track while preserves existing behavior.\nHere\u2019s another difference: in development, putting a string ref on a functional component throws with: Stateless function components cannot have refs. but in production gives you: Element ref was specified as a string but no owner was set.", "commid": "react_issue_11618", "tokennum": 107}], "negative_passages": []}
{"query_id": "q-en-react-34809863e22cfed850b2bbd5fb82cf6a0675a65d19d22dcabaf44145537abc89", "query": "that support `*.tmLanguage`. * Linting provides accurate line numbers after compiling without sourcemaps. * Elements use standard scoping so linters can find usage of out-of-scope components. <ins> ### Debugging [React Developer Tools](https://github.com/facebook/react-devtools) is a [Chrome extension](https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi?hl=en) that allows you to inspect the React component hierarchy in the Chrome Developer Tools. </ins>", "positive_passages": [{"docid": "doc-en-react-2a6eedbe52e90bab8f5538f15adbae0381e1db4f3c78dccc178aacb85f77e833", "text": "I don't know where the right place to link to them is. Maybe \"Getting started\", \"Tutorial\" and \"Tooling integration\"?", "commid": "react_issue_791", "tokennum": 32}], "negative_passages": []}
{"query_id": "q-en-react-3ea985d1ecc0ab09fe963ad918633efcc462876d602e2b15699e358f5de3cc7a", "query": "} export function createLaneMap<T>(initial: T): LaneMap<T> { <del> return new Array(TotalLanes).fill(initial); </del> <ins> // Intentionally pushing one by one. // https://v8.dev/blog/elements-kinds#avoid-creating-holes const laneMap = []; for (let i = 0; i < TotalLanes; i++) { laneMap.push(initial); } return laneMap; </ins> } export function markRootUpdated(", "positive_passages": [{"docid": "doc-en-react-3716929f5f424966d8556311ed5fe7cc53d818b25253edc9de6541f96ad448ed", "text": "After updating react-dom to version 17 the build now includes () which isn't supported by ie11 without polyfilling. Coming from this line. Tested with just the default cra production build to make sure it wasn't a problem with my webpack config and the same issue. Tested using CRA on version 16.9.8 of react and react-dom which works with the production build for ie11.\nConfirmed with https://csb-hznfc- (built from ) which errors with \"SCRIPT438: Object doesn't support property or method 'fill'\".\nAny chance you could confirm the fix on a real IE\nGonna wait to see if a few more bugs get reported in the next few hours. Then will cut a patch.\nShould be fixed in 17.0.1.", "commid": "react_issue_20069", "tokennum": 172}], "negative_passages": []}
{"query_id": "q-en-react-43da6ed3107d08a677a94e7c5385ea2f9c800093187275647e4ad14bacc37606", "query": "echo \"Only docs were updated, stopping build process.\" exit fi <del> npm install -g npm </del> <ins> npm install -g npm@latest-2 </ins> script: - | if [ \"$TEST_TYPE\" = build_website ]; then", "positive_passages": [{"docid": "doc-en-react-6746ac08815bbf89a554f2599c24efc7ee4f226755f4ae042a57183292a2342c", "text": "Since upgrading from beta3 to rc1 I've seen this error a few times in production. Haven't been able to trace the source yet though. cc\nI was unmounting a root during a keyboard event which caused this to happen. I think this has always been a problem? Perhaps we've only been lucky... leaving open just to be sure. EDIT: Could it make sense to have something along the lines of ? Allowing you to schedule things to occur as soon as the current transaction ends.\nThis invariant was new in this release. We also hit one case at FB that I haven't yet investigated. Probably need to change something for the final release.\nI have seen this on RC1 can't find a sequence of actions to repeat it.\nI'm running into this issue as well when conditionally rendering based on state. Not sure how to boil it down to a simple reproducible bug report yet.\nMy issue only happens when I am leveraging FastClick. Didn't happen before 0.14.\nI've found it is because the events are handled in a different order with fastclick, so the batching gets weird...\ne.g. click gets fired before touchEnd, so click handler setState to remove subtree, and then react tries to do something with it in touch end perhaps?", "commid": "react_issue_4865", "tokennum": 278}], "negative_passages": []}
{"query_id": "q-en-react-43da6ed3107d08a677a94e7c5385ea2f9c800093187275647e4ad14bacc37606", "query": "echo \"Only docs were updated, stopping build process.\" exit fi <del> npm install -g npm </del> <ins> npm install -g npm@latest-2 </ins> script: - | if [ \"$TEST_TYPE\" = build_website ]; then", "positive_passages": [{"docid": "doc-en-react-19961fc470123ba131df0c13acdc16dca9ae2f0bc85b5a2da9d0662a1783f6d5", "text": "In this repro, I created 2 buttons and only one is rendered at a time. One button's click handler is hooked up to React's synthetic \"click\" event while the other is hooked up to the native \"click\" event. Even though only one button is rendered at a time, a single click is triggering both click events. This bug can be hit by apps that mix React components with non-React controls (e.g. jQuery UI). I reproed this in Chrome with React 0.13.2. to the button labeled \"One\" Expected: There's a button rendered labeled \"Two\" Actual: The rendered button still has the label \"One\" If you open the console, you'll see \"goToTwo\" and \"goToOne\" which indicates that the \"One\" button's click handler ran and then the \"Two\" button's click handler ran (even though we never saw button \"Two\"\").\nI experimented more and came up with another repro: In this one, you click on a button with a native \"click\" handler which causes the button to go away and an input field to be rendered. It results in this exception: From these 2 repros, it seems something strange is going on when calling from within a native \"click\" handler.\nIt works if you add to the event handler.\nThanks for the workaround. Is the behavior without the by design? It looks like the bad behavior is being caused by the rerender happening synchronously within the native \"click\" handler.\nThis looks bad. We don't do a great job interacting with native events. Sebastian wrote a post about this once-upon-a-time, how native and synthetic event systems are, by and large, not interoperable. Even so, I can't see a reason we should fatal like this. Do you understand what's going wrong here? What a fix might look like?\nThis happens when we handle a click event from a node that's been removed in between when the event is triggered and when React receives it. How should we deal with the case that events fire on detached elements? Should we ignore events for nodes that aren't in the document? I don't think the bug is easily fixable otherwise because we don't have the old event handler after the reconcile that removes that node.\nHere are some additional details about the impact of the bug.", "commid": "react_issue_3790", "tokennum": 505}], "negative_passages": []}
{"query_id": "q-en-react-43da6ed3107d08a677a94e7c5385ea2f9c800093187275647e4ad14bacc37606", "query": "echo \"Only docs were updated, stopping build process.\" exit fi <del> npm install -g npm </del> <ins> npm install -g npm@latest-2 </ins> script: - | if [ \"$TEST_TYPE\" = build_website ]; then", "positive_passages": [{"docid": "doc-en-react-7851a482df6560c8b9755474dda32fba2e00952e4178b5bb7f60e2baae6ce704", "text": "It sounds like this bug is likely to trigger when you use a non-React component (e.g. jQuery UI) in a React single page application and the non-React component triggers a navigation within the app.\nThanks for an excellent bug report and good repro case! I think this happens because we use the \"root id\" to determine which element was clicked. In the repro case there is no \"key\" as part of the root ID for two reasons: 1) It is not a child of a container (multichild) so it doesn't get a key to the root ID. 2) It doesn't have a unique key and doesn't need one because it the button is of a different type. If I make sure that a key is used as part of the root ID the problem is solved: So the problem in the repro isn't that we're firing on a removed node, it is that we're firing the event on the new node. This would be solved if we used a unique ID per instance to identify event handlers instead of a generate root that is non-unique. Which I think we wanted to do anyway. Is there another repro that shows a different issue?", "commid": "react_issue_3790", "tokennum": 253}], "negative_passages": []}
{"query_id": "q-en-react-47682078fb800bc66160ca339307e1645454f18f64804cb150a53e95427ed0d7", "query": "var Component = this._currentElement.type; // Initialize the public class <del> var inst; </del> <ins> var inst = this._constructComponent(publicProps, publicContext); </ins> var renderedElement; <del> if (Component.prototype && Component.prototype.isReactComponent) { if (__DEV__) { ReactCurrentOwner.current = this; try { inst = new Component(publicProps, publicContext, ReactUpdateQueue); } finally { ReactCurrentOwner.current = null; } } else { inst = new Component(publicProps, publicContext, ReactUpdateQueue); } } else { if (__DEV__) { ReactCurrentOwner.current = this; try { inst = Component(publicProps, publicContext, ReactUpdateQueue); } finally { ReactCurrentOwner.current = null; } } else { inst = Component(publicProps, publicContext, ReactUpdateQueue); } if (inst == null || inst.render == null) { renderedElement = inst; warnIfInvalidElement(Component, renderedElement); invariant( inst === null || inst === false || ReactElement.isValidElement(inst), '%s(...): A valid React element (or null) must be returned. You may have ' + 'returned undefined, an array or some other invalid object.', Component.displayName || Component.name || 'Component' ); inst = new StatelessComponent(Component); } </del> <ins> // Support functional components if (!shouldConstruct(Component) && (inst == null || inst.render == null)) { renderedElement = inst; warnIfInvalidElement(Component, renderedElement); invariant( inst === null || inst === false || ReactElement.isValidElement(inst), '%s(...): A valid React element (or null) must be returned. You may have ' + 'returned undefined, an array or some other invalid object.', Component.displayName || Component.name || 'Component' ); inst = new StatelessComponent(Component); </ins> } if (__DEV__) {", "positive_passages": [{"docid": "doc-en-react-ca19df289e02684e61e07a528776d59aafa3f9ae31aa0dfa1ca6abf5d058dfe3", "text": "There appears to have been a change in how is generated between 0.13 and 0.14 which is causing a number of our shallow rendered tests to fail when upgrading because the deepEquals fails on the property. Here is a simple example component which exhibits the issue.\nI've been seeing some similar issues with shallow rendering. My current (messy - sorry!) workaround is this: Let me know if that helps! My version currently breaks some of the Jest tests, but I'm happy to work on this some more and submit a PR.\nThank you very much for this, it's been a tremendous help! While this solved the problem for my test case above it still failed on a large number of our more complex tests. I've been iterating on it and once I have all of our tests passing I'll add the updated version.\nHere is the updated workaround, it works for our 238 tests of varying complexity but I'd be interested to see if it passes all of your tests as well.\nAwesome! If you don't mind trying, what happens if you do and then use the earlier ?\nMuch cleaner thanks, I guess I was in my head too much :)\nI prefer applying a monkey patch, until we have this fixed in react by wrapping TestUtils in my own module:\nThis should be fixed by .", "commid": "react_issue_5292", "tokennum": 278}], "negative_passages": []}
{"query_id": "q-en-react-492afbb3f48cae70bdb81b327c18b39eac6efd1d3e4b48e3d80119a04e0b69c0", "query": "items: - id: flux-overview title: Flux Overview <ins> href: http://facebook.github.io/flux/docs/overview.html </ins> - id: flux-todo-list title: Flux TodoMVC Tutorial <ins> href: http://facebook.github.io/flux/docs/todo-list.html </ins>", "positive_passages": [{"docid": "doc-en-react-184f91d84492376e91bb3ce0eef633ad1d542d121a8387ded7325160c8768b6a", "text": "We're basically keeping 2 copies of documentation in sync and failing. We should just point at and We should maybe make the permalinks on our site redirect or just link offsite. We should also look for links in our docs pointing to those pages and update.\ncc\nalso cc\nDefinitively agreed, we should link all the traffic to the dedicated website. See the Complementary section on Flux website", "commid": "react_issue_2229", "tokennum": 83}], "negative_passages": []}
{"query_id": "q-en-react-49fc40239b15bb355df1899968bc8ef1c66a8b7fc85aba4d2a2ad10fc83c1939", "query": "const Resolved = 2; const Rejected = 3; <del> type EmptyRecord<K, V> = {| </del> <ins> type EmptyRecord<K> = {| </ins> status: 0, suspender: null, key: K, value: null, error: null, <del> next: Record<K, V> | null, previous: Record<K, V> | null, </del> <ins> next: any, // TODO: (issue #12941) previous: any, // TODO: (issue #12941) /** * Proper types would be something like this: * next: Record<K, V> | null, * previous: Record<K, V> | null, */ </ins> |}; type PendingRecord<K, V> = {| status: 1, <del> suspender: Promise<K, V>, </del> <ins> suspender: Promise<V>, </ins> key: K, value: null, error: null, <del> next: Record<K, V> | null, previous: Record<K, V> | null, </del> <ins> next: any, // TODO: (issue #12941) previous: any, // TODO: (issue #12941) /** * Proper types would be something like this: * next: Record<K, V> | null, * previous: Record<K, V> | null, */ </ins> |}; type ResolvedRecord<K, V> = {|", "positive_passages": [{"docid": "doc-en-react-6b3c5af2ada23f47aa80eedc03ca3a83d950eba15ef87f3dd6836f67ab1f9949", "text": "In we landed a change to the Flow types in , making the types for the various types recursive with their and properties. On that PR we may have been running an older version of Flow - I'm not having luck finding the record of when Flow ran for that PR, so not sure. In any case, that PR was merged even though it had the recursive Flow type definitions, plus one or more Flow errors which were unrelated and not detected. The problem with the recursive type definitions is that recent versions of Flow will go into an infinite loop if they try to infer types which are recursive. The solution may be to add more detail to those types, but to unblock things we temporarily made them looser type definitions.", "commid": "react_issue_12941", "tokennum": 154}], "negative_passages": []}
{"query_id": "q-en-react-4a709316123d3ccb746754b3bd9cac1c7364e1c4ecf808c2212b13f3ae87a6cb", "query": "export const enableSelectiveHydration = false; export const enableChunksAPI = false; export const exposeConcurrentModeAPIs = __EXPERIMENTAL__; <del> export const warnAboutShorthandPropertyCollision = false; </del> <ins> export const warnAboutShorthandPropertyCollision = true; </ins> export const enableSchedulerDebugging = false; export const debugRenderPhaseSideEffectsForStrictMode = true; export const disableJavaScriptURLs = false;", "positive_passages": [{"docid": "doc-en-react-dc8da7a6c3fb2961be71e65b461606628545463378521ea8f9e19712a73591ca", "text": "I a \"bug\" today that made me spent 1h figuring out what was going on: I'm using an external component that accepts a prop in order to set the of the root element, but this same component also accepts a prop which I wasn't passing, and by default, it was set to . The result: React didn't throw an error nor a warning, however, the resulting element in the DOM didn't contain either or , and since the element had a default coming from a CSS class, it took me a while to figure out why the color that I was passing wasn't being applied, and instead it was using the one from the CSS class. See: What I reported above was the case. I other cases as a bonus, as when I was playing with this they also seemed weird to me. On I define the same properties, but because I change the order, it works. On the toggleable ones, initially I can see the background, but after changing it never appears anymore. I'm not sure if I created those extra \"test cases\" correctly. My main concern is really around static1 not outputting anything on the console as a warning. Related issues: I wonder if ( should have covered this?\nThis issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution.\nClosing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information. Thank you!\nit seems that the bot automatically closed the issue, but this still needs action. I took a time to investigate it, and I realized that the work Sophie has done covers this case, but there's just one problem: it's disabled under a . I built it locally and flipped the flag, and it works: I can see the helpful warning. It was flagged in , and as per the PR, the original intention was to unflag it on the next minor. Since then we had at least 4 new minor versions, but it is still flagged. Is there a special reason for that or was it just forgotten? tagging you since you this flag, so I'm hoping you can give context here.\nCan we unflag this?\nThis was released.", "commid": "react_issue_16393", "tokennum": 488}], "negative_passages": []}
{"query_id": "q-en-react-4ade246663484a6c7002059bc3cd0c3641cedcfebfef04da9da615081bbf11a0", "query": "--- id: flux-todo-list title: Flux TodoMVC Tutorial <del> prev: flux-overview.html </del> --- <del> To demonstrate the Flux architecture with some example code, let's take on the classic TodoMVC application. The entire application is available in the Flux GitHub repo within the [flux-todomvc](https://github.com/facebook/flux/tree/master/examples/flux-todomvc) example directory, but let's walk through the development of it a step at a time. To begin, we'll need some boilerplate and get up and running with a module system. Node's module system, based on CommonJS, will fit the bill very nicely and we can build off of [react-boilerplate](https://github.com/petehunt/react-boilerplate) to get up and running quickly. Assuming you have npm installed, simply clone the react-boilerplate code from GitHub, and navigate into the resulting directory in Terminal (or whatever CLI application you like). Next run the npm scripts to get up and running: `npm install`, then `npm run build`, and lastly `npm start` to continuously build using Browserify. The TodoMVC example has all this built into it as well, but if you're starting with react-boilerplate make sure you edit your package.json file to match the file structure and dependencies described in the TodoMVC example's [package.json](https://github.com/facebook/flux/tree/master/examples/flux-todomvc/package.json), or else your code won't match up with the explanations below. Source Code Structure --------------------- The resulting index.js file may be used as the entry point into our app, but we'll put most of our code in a 'js' directory. Let's let Browserify do its thing, and now we'll open a new tab in Terminal (or a GUI file browser) to look at the directory. It should look something like this: ``` myapp | + ... + js | + app.js + bundle.js // generated by Browserify whenever we make changes. + index.html + ... ``` Next we'll dive into the js directory, and layout our application's primary directory structure: ``` myapp | + ... + js | + actions + components // all React components, both views and controller-views + constants + dispatcher + stores + app.js + bundle.js + index.html + ... ``` Using the Dispatcher -------------------- We'll use the dispatcher from the [Flux GitHub repository](https://github.com/facebook/flux), but let's go over how to get it into our project, how it works and how we'll use it. The dispatcher's source code is written in [ECMAScript 6](https://github.com/lukehoban/es6features), the future version of JavaScript. To use the future of JS in today's browser's we need to transpile it back to a version of JS that browsers can use. We perform this build step, transpiling from ES6 into common JavaScript, using npm. You can get up and running with the dispatcher in a variety of ways, but perhaps the simplest is to use [Michael Jackson](https://twitter.com/mjackson)'s npm module version of the Flux project, called [react-dispatcher](https://www.npmjs.org/package/react-dispatcher): ``` npm install react-dispatcher ``` Afterward, you can require the dispatcher in your project's modules like so: ```javascript var Dispatcher = require('Flux').Dispatcher; ``` Alternatively, you can clone the Flux repo, run the Gulp-based build script with `npm install`, and then simply copy the dispatcher and invariant modules located inside flux/lib/ to the dispatcher directory for your project. This the what we did in the [example code](https://github.com/facebook/flux/tree/master/examples/flux-todomvc/js/dispatcher). The two most important methods that the dispatcher exposes publically are register() and dispatch(). We'll use register() within our stores to register each store's callback. We'll use dispatch() within our action creators to trigger the invocation of the callbacks. ```javascript class Dispatcher { constructor() { this._callbacks = {}; this._isPending = {}; this._isHandled = {}; this._isDispatching = false; this._pendingPayload = null; } /** * Registers a callback to be invoked with every dispatched payload. * * @param {function} callback * @return {string} */ register(callback) { var id = _prefix + _lastID++; this._callbacks[id] = callback; return id; } // ... /** * Dispatches a payload to all registered callbacks. * * @param {object} payload */ dispatch(payload) { invariant( !this._isDispatching, 'Dispatch.dispatch(...): Cannot dispatch in the middle of a dispatch.' ); this._startDispatching(payload); try { for (var id in this._callbacks) { if (this._isPending[id]) { continue; } this._invokeCallback(id); } } finally { this._stopDispatching(); } } // ... _invokeCallback(id) { this._isPending[id] = true; this._callbacks[id](this._pendingPayload); this._isHandled[id] = true; } _startDispatching(payload) { for (var id in this._callbacks) { this._isPending[id] = false; this._isHandled[id] = false; } this._pendingPayload = payload; this._isDispatching = true; } _stopDispatching() { this._pendingPayload = null; this._isDispatching = false; } } ``` Now we are all set to create a dispatcher that is more specific to our app, which we'll call AppDispatcher. ```javascript var Dispatcher = require('./Dispatcher'); var merge = require('react/lib/merge'); var AppDispatcher = merge(Dispatcher.prototype, { /** * A bridge function between the views and the dispatcher, marking the action * as a view action. Another variant here could be handleServerAction. * @param {object} action The data coming from the view. */ handleViewAction: function(action) { this.dispatch({ source: 'VIEW_ACTION', action: action }); } }); module.exports = AppDispatcher; ``` Now we've created an implementation that is a bit more specific to our needs, with a helper function we can use when we create actions. We might expand on this later to provide a separate helper for server updates, but for now this is all we need. You don't actually need to create an AppDispatcher in every application, but we wanted to show it here as an example. The creation of the AppDispatcher allows us to extend the functionality of the Dispatcher. In this application, for example, we have provided metadata about the source of the action outside of the action itself. Creating Stores ---------------- We can use Node's EventEmitter to get started with a store. We need EventEmitter to broadcast the 'change' event to our controller-views. So let's take a look at what that looks like. I've omitted some of the code for the sake of brevity, but for the full version see [TodoStore.js](https://github.com/Facebook/flux/blob/master/examples/flux-todomvc/js/stores/TodoStore.js) in the TodoMVC example code. ```javascript var AppDispatcher = require('../dispatcher/AppDispatcher'); var EventEmitter = require('events').EventEmitter; var TodoConstants = require('../constants/TodoConstants'); var merge = require('react/lib/merge'); var CHANGE_EVENT = 'change'; var _todos = {}; // collection of todo items /** * Create a TODO item. * @param {string} text The content of the TODO */ function create(text) { // Using the current timestamp in place of a real id. var id = Date.now(); _todos[id] = { id: id, complete: false, text: text }; } /** * Delete a TODO item. * @param {string} id */ function destroy(id) { delete _todos[id]; } var TodoStore = merge(EventEmitter.prototype, { /** * Get the entire collection of TODOs. * @return {object} */ getAll: function() { return _todos; }, emitChange: function() { this.emit(CHANGE_EVENT); }, /** * @param {function} callback */ addChangeListener: function(callback) { this.on(CHANGE_EVENT, callback); }, /** * @param {function} callback */ removeChangeListener: function(callback) { this.removeListener(CHANGE_EVENT, callback); }, dispatcherIndex: AppDispatcher.register(function(payload) { var action = payload.action; var text; switch(action.actionType) { case TodoConstants.TODO_CREATE: text = action.text.trim(); if (text !== '') { create(text); TodoStore.emitChange(); } break; case TodoConstants.TODO_DESTROY: destroy(action.id); TodoStore.emitChange(); break; // add more cases for other actionTypes, like TODO_UPDATE, etc. } return true; // No errors. Needed by promise in Dispatcher. }) }); module.exports = TodoStore; ``` There are a few important things to note in the above code. To start, we are maintaining a private data structure called _todos. This object contains all the individual to-do items. Because this variable lives outside the class, but within the closure of the module, it remains private \u2014 it cannot be directly changed from the outside. This helps us preserve a distinct input/output interface for the flow of data by making it impossible to update the store without using an action. Another important part is the registration of the store's callback with the dispatcher. We pass in our payload handling callback to the dispatcher and preserve the index that this store has in the dispatcher's registry. The callback function currently only handles two actionTypes, but later we can add as many as we need. Listening to Changes with a Controller-View ------------------------------------------- We need a React component near the top of our component hierarchy to listen for changes in the store. In a larger app, we would have more of these listening components, perhaps one for every section of the page. In Facebook's Ads Creation Tool, we have many of these controller-like views, each governing a specific section of the UI. In the Lookback Video Editor, we only had two: one for the animated preview and one for the image selection interface. Here's one for our TodoMVC example. Again, this is slightly abbreviated, but for the full code you can take a look at the TodoMVC example's [TodoApp.react.js](https://github.com/facebook/flux/blob/master/examples/flux-todomvc/js/components/TodoApp.react.js) ```javascript /** @jsx React.DOM */ var Footer = require('./Footer.react'); var Header = require('./Header.react'); var MainSection = require('./MainSection.react'); var React = require('react'); var TodoStore = require('../stores/TodoStore'); function getTodoState() { return { allTodos: TodoStore.getAll() }; } var TodoApp = React.createClass({ getInitialState: function() { return getTodoState(); }, componentDidMount: function() { TodoStore.addChangeListener(this._onChange); }, componentWillUnmount: function() { TodoStore.removeChangeListener(this._onChange); }, /** * @return {object} */ render: function() { return ( <div> <Header /> <MainSection allTodos={this.state.allTodos} areAllComplete={this.state.areAllComplete} /> <Footer allTodos={this.state.allTodos} /> </div> ); }, _onChange: function() { this.setState(getTodoState()); } }); module.exports = TodoApp; ``` Now we're in our familiar React territory, utilizing React's lifecycle methods. We set up the initial state of this controller-view in getInitialState(), register an event listener in componentDidMount(), and then clean up after ourselves within componentWillUnmount(). We render a containing div and pass down the collection of states we got from the TodoStore. The Header component contains the primary text input for the application, but it does not need to know the state of the store. The MainSection and Footer do need this data, so we pass it down to them. More Views ---------- At a high level, the React component hierarchy of the app looks like this: ```javascript <TodoApp> <Header> <TodoTextInput /> <MainSection> <ul> <TodoItem /> </ul> </MainSection> </Header> </TodoApp> ``` If a TodoItem is in edit mode, it will also render a TodoTextInput as a child. Let's take a look at how some of these components display the data they receive as props, and how they communicate through actions with the dispatcher. The MainSection needs to iterate over the collection of to-do items it received from TodoApp to create the list of TodoItems. In the component's render() method, we can do that iteration like so: ```javascript var allTodos = this.props.allTodos; for (var key in allTodos) { todos.push(<TodoItem key={key} todo={allTodos[key]} />); } return ( <section id=\"main\"> <ul id=\"todo-list\">{todos}</ul> </section> ); ``` Now each TodoItem can display its own text, and perform actions utilizing its own ID. Explaining all the different actions that a TodoItem can invoke in the TodoMVC example goes beyond the scope of this article, but let's just take a look at the action that deletes one of the to-do items. Here is an abbreviated version of the TodoItem: ```javascript /** @jsx React.DOM */ var React = require('react'); var TodoActions = require('../actions/TodoActions'); var TodoTextInput = require('./TodoTextInput.react'); var TodoItem = React.createClass({ propTypes: { todo: React.PropTypes.object.isRequired }, render: function() { var todo = this.props.todo; return ( <li key={todo.id}> <label> {todo.text} </label> <button className=\"destroy\" onClick={this._onDestroyClick} /> </li> ); }, _onDestroyClick: function() { TodoActions.destroy(this.props.todo.id); } }); module.exports = TodoItem; ``` With a destroy action available in our library of TodoActions, and a store ready to handle it, connecting the user's interaction with application state changes could not be simpler. We just wrap our onClick handler around the destroy action, provide it with the id, and we're done. Now the user can click the destroy button and kick off the Flux cycle to update the rest of the application. Text input, on the other hand, is just a bit more complicated because we need to hang on to the state of the text input within the React component itself. Let's take a look at how TodoTextInput works. As you'll see below, with every change to the input, React expects us to update the state of the component. So when we are finally ready to save the text inside the input, we will put the value held in the component's state in the action's payload. This is UI state, rather than application state, and keeping that distinction in mind is a good guide for where state should live. All application state should live in the store, while components occasionally hold on to UI state. Ideally, React components preserve as little state as possible. Because TodoTextInput is being used in multiple places within our application, with different behaviors, we'll need to pass the onSave method in as a prop from the component's parent. This allows onSave to invoke different action creator methods depending on where it is used. ```javascript /** @jsx React.DOM */ var React = require('react'); var ReactPropTypes = React.PropTypes; var ENTER_KEY_CODE = 13; var TodoTextInput = React.createClass({ propTypes: { className: ReactPropTypes.string, id: ReactPropTypes.string, placeholder: ReactPropTypes.string, onSave: ReactPropTypes.func.isRequired, value: ReactPropTypes.string }, getInitialState: function() { return { value: this.props.value || '' }; }, /** * @return {object} */ render: function() /*object*/ { return ( <input className={this.props.className} id={this.props.id} placeholder={this.props.placeholder} onBlur={this._save} onChange={this._onChange} onKeyDown={this._onKeyDown} value={this.state.value} autoFocus={true} /> ); }, /** * Invokes the callback passed in as onSave, allowing this component to be * used in different ways. */ _save: function() { this.props.onSave(this.state.value); this.setState({ value: '' }); }, /** * @param {object} event */ _onChange: function(/*object*/ event) { this.setState({ value: event.target.value }); }, /** * @param {object} event */ _onKeyDown: function(event) { if (event.keyCode === ENTER_KEY_CODE) { this._save(); } } }); module.exports = TodoTextInput; ``` The Header passes in the onSave method as a prop to allow the TodoTextInput to create new to-do items: ```javascript /** @jsx React.DOM */ var React = require('react'); var TodoActions = require('../actions/TodoActions'); var TodoTextInput = require('./TodoTextInput.react'); var Header = React.createClass({ /** * @return {object} */ render: function() { return ( <header id=\"header\"> <h1>todos</h1> <TodoTextInput id=\"new-todo\" placeholder=\"What needs to be done?\" onSave={this._onSave} /> </header> ); }, /** * Event handler called within TodoTextInput. * Defining this here allows TodoTextInput to be used in multiple places * in different ways. * @param {string} text */ _onSave: function(text) { TodoActions.create(text); } }); module.exports = Header; ``` In a different context, such as in editing mode for an existing to-do item, we might pass an onSave callback that invokes `TodoActions.update(text)` instead. Creating Actions with Semantic Methods -------------------------------------- Here is the basic code for the two action creator methods we used above in our views: ```javascript /** * TodoActions */ var AppDispatcher = require('../dispatcher/AppDispatcher'); var TodoConstants = require('../constants/TodoConstants'); var TodoActions = { /** * @param {string} text */ create: function(text) { AppDispatcher.handleViewAction({ actionType: TodoConstants.TODO_CREATE, text: text }); }, /** * @param {string} id */ destroy: function(id) { AppDispatcher.handleViewAction({ actionType: TodoConstants.TODO_DESTROY, id: id }); }, }; module.exports = TodoActions; ``` As you can see, we really would not need to have the helpers AppDispatcher.handleViewAction() or TodoActions.create(). We could, in theory, call AppDispatcher.dispatch() directly and provide a payload. But as our application grows, having these helpers keeps the code clean and semantic. It's just a lot cleaner to write TodoActions.destroy(id) instead of writing a whole lot of things that our TodoItem shouldn't have to know about. The payload produced by the TodoActions.create() will look like: ```javascript { source: 'VIEW_ACTION', action: { type: 'TODO_CREATE', text: 'Write blog post about Flux' } } ``` This payload is provided to the TodoStore through its registered callback. The TodoStore then broadcasts the 'change' event, and the MainSection responds by fetching the new collection of to-do items from the TodoStore and changing its state. This change in state causes the TodoApp component to call its own render() method, and the render() method of all of its descendents. Start Me Up ----------- The bootstrap file of our application is app.js. It simply takes the TodoApp component and renders it in the root element of the application. ```javascript /** @jsx React.DOM */ var React = require('react'); var TodoApp = require('./components/TodoApp.react'); React.renderComponent( <TodoApp />, document.getElementById('todoapp') ); ``` Dependency Management in the Dispatcher ---------------------------------------------- As our application grows beyond this simple application to contain multiple stores, we'll need a way to be able to manage dependencies between them. That is, Store A might need to derive data based on Store B's data, so Store A would need Store B to update itself first. This functionality is available with the Dispatcher's waitFor() method. We would call waitFor() within the store's registered callback like so: ```javascript Dispatcher.waitFor([StoreB.dispatcherIndex, StoreC.dispatcherIndex]); // now do things, knowing that both StoreB and StoreC have updated ``` In the source code, you can see that we are interupting the synchronous iteration over the callbacks and starting a new iteration of callbacks based on the array of dispatcherIndexes passed into waitFor(). ```javascript /** * Waits for the callbacks specified to be invoked before continuing execution * of the current callback. This method should only be used by a callback in * response to a dispatched payload. * * @param {array<string>} ids */ waitFor(ids) { invariant( this._isDispatching, 'Dispatcher.waitFor(...): Must be invoked while dispatching.' ); for (var ii = 0; ii < ids.length; ii++) { var id = ids[ii]; if (this._isPending[id]) { invariant( this._isHandled[id], 'Dispatcher.waitFor(...): Circular dependency detected while ' + 'waiting for `%s`.', id ); continue; } invariant( this._callbacks[id], 'Dispatcher.waitFor(...): `%s` does not map to a registered callback.', id ); this._invokeCallback(id); } } ``` Now within the store's callback we can explicitly wait for any dependencies to first update before moving forward. However, if Store A waits for Store B, and B waits for A, then a circular dependency will occur. To help prevent this situation, the dispatcher will throw an error in the browser console if we accidentally have two stores that are waiting for each other. The Future of Flux ------------------ A lot of people ask if Facebook will release Flux as an open source framework. Really, Flux is just an architecture, not a framework. But perhaps a Flux boilerplate project might make sense, if there is enough interest. Please let us know if you'd like to see us do this. Thanks for taking the time to read about how we build client-side applications at Facebook. We hope Flux proves as useful to you as it has to us. </del> <ins> This page has been moved to the Flux website. [View it there](http://facebook.github.io/flux/docs/todo-list.html). </ins>", "positive_passages": [{"docid": "doc-en-react-184f91d84492376e91bb3ce0eef633ad1d542d121a8387ded7325160c8768b6a", "text": "We're basically keeping 2 copies of documentation in sync and failing. We should just point at and We should maybe make the permalinks on our site redirect or just link offsite. We should also look for links in our docs pointing to those pages and update.\ncc\nalso cc\nDefinitively agreed, we should link all the traffic to the dedicated website. See the Complementary section on Flux website", "commid": "react_issue_2229", "tokennum": 83}], "negative_passages": []}
{"query_id": "q-en-react-4d1f3f7ee457e8f03ce85aeb8da4d1460b2b7154b5ae8c25b50312f600c18365", "query": "* `Object.create` \u2013 Provided by `es5-sham.js` from [kriskowal's es5-shim](https://github.com/kriskowal/es5-shim). * `console.*` \u2013 Only needed when using the unminified build. If you need to polyfill this, try [paulmillr's console-polyfill](https://github.com/paulmillr/console-polyfill). <ins> ### Cross-browser Issues Although React is pretty good at abstracting browser differences, some browsers are limited or present quirky behaviors that we couldn't find a workaround. #### onScroll event on IE8 On IE8 the `onScroll` event doesn't bubbles and IE8 doesn't have an API to define handlers to the capturing phase of an event, meaning there is no way for React to listen to these events. Currently a handler to this event is ignored on IE8. See the [onScroll doesn't work in IE8](https://github.com/facebook/react/issues/631) GitHub issue for more information. </ins>", "positive_passages": [{"docid": "doc-en-react-a932c0004128968176c961fe7b2a4c24de84c793eeb3dd4b65cbbea01408e142", "text": "Here's an example: (no jsfiddle because that's broken in IE8)\nI tried to fix this bug yesterday but had a bad time trying to find a fix for a similar cases. I looked at current well maintained libraries and didn't find a way to make scroll bubble or capture it on IE8. Seems like trying to fix it would be a waste of time and would make code much complex, for a browser that is slowly dying. My suggestion is to point that out on the documentation.\nSeems like this isn't so easy. Let's do what says and document it.\ndo you think that we should do a everytime someone uses onScroll on any browser or would that be annoying? I would say it would be annoying but it would also be very frustrating to figure that it's a React limitation after some hours of debugging on IE8 (ugh!)\n+1 on the warning -- would be super helpful.\nreopening so we can add a warning\nWarning was in\nNow that events are listened on demand, maybe the warning should be moved to method, where support is already checked?\nIt also prints the warning if you render on the server, its annoying :/\nThat's odd, I wouldn't expect that code to run at all when using server rendering.\nI see this warning when I'm doing with . Any chance to disable it?\nI also see this error when using ssr\nThis is happening to me with JSDOM as well and in my case our team project standards aren't going to accommodate leaving these errors in the console when tests are run. How can I suppress or stub this out. It's not just obnoxious it is preventing me from getting my work merged in our project.\n/ - I am now seeing this error after upgrading my version of Enzyme to . Did you find a way to suppress these warnings for JSDOM?\nIf you're having problems please file a new issue. Nobody actively reads old issues, and requests for help here will get lost.", "commid": "react_issue_631", "tokennum": 421}], "negative_passages": []}
{"query_id": "q-en-react-4ea2cc92e2a4b7cb71fe9907df30e1a5477772eb55fe5a3809dd716aa0aa3557", "query": "<div className=\"content\" dangerouslySetInnerHTML={{ <del> __html: converter.makeHtml(this.state.value) </del> <ins> __html: marked(this.state.value, {sanitize: true}) </ins> }} /> </div>", "positive_passages": [{"docid": "doc-en-react-bda68aba5b773f0e231d8ae9f598c5dea11ff75961a86d42353566558f7ff8f7", "text": "Since copy+pasting our code makes it too easy for people to XSS themselves, lets just add a comment in there about it.\nPR at - let me know if that's what you had in mind!\nMy intuition is that it makes more sense to fix the example (call a sanitization library) or to change the example completely (demonstrate something else that is safer). It looks really bad to have a security warning on the homepage of the react site. Makes it seem like our framework encourages unsafe operations, rather than a safe-by-default way of doing things.\nShould switch the demo to use a different library like markdown-js that escapes everything and doesn't support HTML:\nmarkdown-js looks good. First attempt: ,output Code licensed if someone wants to turn this into a coherent example; I've signed the CLA.\nThat's a good suggestion too :) - what are your thoughts? I'm happy to change the example to use like people have suggested above. nice usage example :+1:\nUh yea, that sounds fine to me. This behavior is definitely non-standard markdown but it's an example so not a big deal. We should probably do the same for the tutorial while we're here. And it's on cdnjs so that's all pretty easy:\nJust going to use marked instead, which I'm already familiar with and has an option to sanitize input.", "commid": "react_issue_3501", "tokennum": 304}], "negative_passages": []}
{"query_id": "q-en-react-53c950b809034dd826390ae3198a9c2902ccb297a244a64b1d7581372e79ec7d", "query": "listeners: null, onChange: _handleChange.bind(inst), }; <ins> if (__DEV__) { inst._wrapperState.controlled = props.checked !== undefined || props.value !== undefined; } </ins> }, updateWrapper: function(inst) {", "positive_passages": [{"docid": "doc-en-react-2d50644914e10b5751903bb65355dc5f5ba6e3cbb7af72fb79c683173a5cbe53", "text": "A component should either be using uncontrolled inputs or controlled inputs, but not both (they should pick a single paradigm, for the lifetime of the component). As a result, an instance of an input should never switch from controlled to uncontrolled (or vice versa). We should warn when an input that was previously controlled becomes uncontrolled, or vice versa.\nCould you provide some code as to how a controlled input becomes uncontrolled and vice versa?\nI just got this warning, can anyone point me to an explanation with a bit more detail? ty\nput your code in a stackoverflow question, and link it here.\nnewswim Read about controlled components and uncontrolled components. Choose one (preferably controlled components), and don't ever use uncontrolled components. If you are using controlled components, make sure you never pass a or to React. And yes, is correct, this is better addressed on StackOverflow.\nI don't consider an input's value being null or undefined as a qualifying factor in determining if an input is controlled or uncontrolled. Controlled forms are a paradigm that may share some qualities with uncontrolled forms. It's about listening to changes and updating the state of the value, but React shouldn't stipulate that the value can't be undefined. It's an additional burden to those following good practice in using controlled forms. This warning should occur if both defaultValue and value props are used throughout the input's lifecycle.\nI agree, but in the sense that they shouldn't be a single component at all, they should be two separate. Regardless I would say that actually providing the correct string value to an interactive component that expects a string value seems like a rather good practice. Otherwise you will have two distinct value states and , but both being intended to mean the exact same thing. No, because being or makes it uncontrolled by definition and you shouldn't switch between controlled and uncontrolled.", "commid": "react_issue_5821", "tokennum": 422}], "negative_passages": []}
{"query_id": "q-en-react-56218fdf9cc09dd82e3b50c9eb6eea83dd72340820597f54d64c39cd47343675", "query": "): void { if (__DEV__) { currentHookNameInDev = 'useImperativeHandle'; <ins> warning( typeof create === 'function', 'Expected useImperativeHandle() second argument to be a function ' + 'that creates a handle. Instead received: %s.', create !== null ? typeof create : 'null', ); </ins> } // TODO: If deps are provided, should we skip comparing the ref itself? const nextDeps =", "positive_passages": [{"docid": "doc-en-react-32fed7447c33e1c49292377f28ba22b1f003566fcb0c01f418bb8b8e131f1319", "text": "I've noticed a strange bug with the react redux opt-in. If i use it with a connected class component, everything is ok: If i use it with a connected functional component that use with , i obtain a strange error: in method. I create a codepen to reproduce the issue: PS: Sorry for the cors error, but i don't find the way to add as cdn\nI believe the issue here is that expects the second argument to be a function that returns the reference: See: for more information about the API of the hook. Maybe the error thrown could be more clear?\nYou're right, accept a function as second argument. A warning on wrong argument type could be a good idea.\nIll take this issue on\nSure\ni get TypeError: React.useImperativeMethods is not a function in 16.8.0-alpha.1 but when back to 16.7.0-alpha.2 not get this error\nThe hook was renamed in this PR: Most likely between the 16.7 alpha and 16.8 alpha\nYeah, it was renamed.\nyes it work good after rename it where i can get changes between alpha version ?\nCommit log. We don't write changelogs for alphas.\nI'm taking this in since we want to get Hooks out sooner.\nalright np", "commid": "react_issue_14629", "tokennum": 277}], "negative_passages": []}
{"query_id": "q-en-react-564d32c40fb2c0c6d1a71ba75d5b644cc5c140e76114a8e2db89df198345e08a", "query": "}); ``` <del> This is a special API that intentionally makes it difficult to insert raw HTML, but for Showdown we'll take advantage of this backdoor. </del> <ins> This is a special API that intentionally makes it difficult to insert raw HTML, but for marked we'll take advantage of this backdoor. </ins> <del> **Remember:** by using this feature you're relying on Showdown to be secure. </del> <ins> **Remember:** by using this feature you're relying on marked to be secure. In this case, we pass `sanitize: true` which tells marked to escape any HTML markup in the source instead of passing it through unchanged. </ins> ### Hook up the data model", "positive_passages": [{"docid": "doc-en-react-bda68aba5b773f0e231d8ae9f598c5dea11ff75961a86d42353566558f7ff8f7", "text": "Since copy+pasting our code makes it too easy for people to XSS themselves, lets just add a comment in there about it.\nPR at - let me know if that's what you had in mind!\nMy intuition is that it makes more sense to fix the example (call a sanitization library) or to change the example completely (demonstrate something else that is safer). It looks really bad to have a security warning on the homepage of the react site. Makes it seem like our framework encourages unsafe operations, rather than a safe-by-default way of doing things.\nShould switch the demo to use a different library like markdown-js that escapes everything and doesn't support HTML:\nmarkdown-js looks good. First attempt: ,output Code licensed if someone wants to turn this into a coherent example; I've signed the CLA.\nThat's a good suggestion too :) - what are your thoughts? I'm happy to change the example to use like people have suggested above. nice usage example :+1:\nUh yea, that sounds fine to me. This behavior is definitely non-standard markdown but it's an example so not a big deal. We should probably do the same for the tutorial while we're here. And it's on cdnjs so that's all pretty easy:\nJust going to use marked instead, which I'm already familiar with and has an option to sanitize input.", "commid": "react_issue_3501", "tokennum": 304}], "negative_passages": []}
{"query_id": "q-en-react-573855f4ba070faddf901142e798030a25e3a074f22729a1ab2086903f4dbde1", "query": "} } <ins> function shouldConstruct(Component) { return Component.prototype && Component.prototype.isReactComponent; } </ins> /** * ------------------ The Life-Cycle of a Composite Component ------------------ *", "positive_passages": [{"docid": "doc-en-react-ca19df289e02684e61e07a528776d59aafa3f9ae31aa0dfa1ca6abf5d058dfe3", "text": "There appears to have been a change in how is generated between 0.13 and 0.14 which is causing a number of our shallow rendered tests to fail when upgrading because the deepEquals fails on the property. Here is a simple example component which exhibits the issue.\nI've been seeing some similar issues with shallow rendering. My current (messy - sorry!) workaround is this: Let me know if that helps! My version currently breaks some of the Jest tests, but I'm happy to work on this some more and submit a PR.\nThank you very much for this, it's been a tremendous help! While this solved the problem for my test case above it still failed on a large number of our more complex tests. I've been iterating on it and once I have all of our tests passing I'll add the updated version.\nHere is the updated workaround, it works for our 238 tests of varying complexity but I'd be interested to see if it passes all of your tests as well.\nAwesome! If you don't mind trying, what happens if you do and then use the earlier ?\nMuch cleaner thanks, I guess I was in my head too much :)\nI prefer applying a monkey patch, until we have this fixed in react by wrapping TestUtils in my own module:\nThis should be fixed by .", "commid": "react_issue_5292", "tokennum": 278}], "negative_passages": []}
{"query_id": "q-en-react-5a4258bbfee395956fead0d91f28e8323df92fe2dd31dd6193563ef066367fc6", "query": "); } <ins> function optionPostMount() { var inst = this; ReactDOMOption.postMountWrapper(inst); } </ins> // There are so many media events, it makes sense to just // maintain a list rather than create a `trapBubbledEvent` for each var mediaEvents = {", "positive_passages": [{"docid": "doc-en-react-02f66d4e335d6ddaefdaada0c5924337c1569646c887a9e0f46ffcf90b1e6c5d", "text": "Appears to be working in Firefox but at least Chrome & Safari are broken. Should be a really recent regression so very few possible changes to blame... Easiest repo: the todo list on our homepage.\nJust a heads up but this still seems to be an issue even on 15.4.1. I've been struggling to reproduce this because it seems to be some sort of ninja bug. Nevertheless, I was wondering if anyone is still dealing with this problem?\nI haven't seen anything.\nI'm still seeing this issue.\nPlease open a new issue with a simplified repro case if you're still seeing this!", "commid": "react_issue_6445", "tokennum": 133}], "negative_passages": []}
{"query_id": "q-en-react-5c9172670a96392cc46167f8a8df1ac26b06a95215bd7af607434f0d28034026", "query": "var ReactServerRendering; var ReactTestUtils; <del> var cx; </del> var reactComponentExpect; var mocks; describe('ReactCompositeComponent', function() { beforeEach(function() { <del> cx = require('cx'); </del> mocks = require('mocks'); reactComponentExpect = require('reactComponentExpect');", "positive_passages": [{"docid": "doc-en-react-a25328977cbf76bc3b508d745231e0aa56e3f7d590ad2f7ceaf276e749ebae16", "text": "This has no dependencies so I think we should either publish it as a standalone module or direct people to something else from the community. I'm inclined to do the latter since it means we can wash our hands of it. Our internal usage of is tied to our transforms so we've said no to features that would be useful to others outside FB. I'm concerned we'd do that again. Any suggestions for existing projects that we can point to?\nCan't we just link to a bunch of \"useful scripts\" in the docs and leave it at that? People are free to use/modify them, it's implied they're not being maintained and are there just for getting people started. I feel like a lot of people don't understand the current state of , but expect them to be full-blown frameworks and updated with every feature conceivable. Publishing on NPM kind of continues that trend and I suspect no-one on Team React really cares about the addons enough. So I would say, make them available in the docs (as code/files) and let the community sort out publishing/improving/direction.\n...Can I \"steal\" the code and post it somewhere else under my name? I do need it for another CSS repo of mine, and it's really not React-specific.\nAfter talking with Jed at the conference, I think I'll just point people at\nPete hunt already has react-classset module on npm I believe as well\nAccording to the react-classset has been deprecated in favor of the above mentioned library.\nIt is. They're pretty much the same except for some negligible differences so I deprecated the former (the latter has an active maintainer).", "commid": "react_issue_2910", "tokennum": 368}], "negative_passages": []}
{"query_id": "q-en-react-61cf5967e634bfa3a5a4c688733f59ab52171ee5dbc7d9b8cce30bf75b34c564", "query": "var didWarnValueNull = false; var didWarnValueDefaultValue = false; var didWarnCheckedDefaultChecked = false; <ins> var didWarnControlledToUncontrolled = false; var didWarnUncontrolledToControlled = false; </ins> function forceUpdateIfMounted() { if (this._rootNodeID) {", "positive_passages": [{"docid": "doc-en-react-2d50644914e10b5751903bb65355dc5f5ba6e3cbb7af72fb79c683173a5cbe53", "text": "A component should either be using uncontrolled inputs or controlled inputs, but not both (they should pick a single paradigm, for the lifetime of the component). As a result, an instance of an input should never switch from controlled to uncontrolled (or vice versa). We should warn when an input that was previously controlled becomes uncontrolled, or vice versa.\nCould you provide some code as to how a controlled input becomes uncontrolled and vice versa?\nI just got this warning, can anyone point me to an explanation with a bit more detail? ty\nput your code in a stackoverflow question, and link it here.\nnewswim Read about controlled components and uncontrolled components. Choose one (preferably controlled components), and don't ever use uncontrolled components. If you are using controlled components, make sure you never pass a or to React. And yes, is correct, this is better addressed on StackOverflow.\nI don't consider an input's value being null or undefined as a qualifying factor in determining if an input is controlled or uncontrolled. Controlled forms are a paradigm that may share some qualities with uncontrolled forms. It's about listening to changes and updating the state of the value, but React shouldn't stipulate that the value can't be undefined. It's an additional burden to those following good practice in using controlled forms. This warning should occur if both defaultValue and value props are used throughout the input's lifecycle.\nI agree, but in the sense that they shouldn't be a single component at all, they should be two separate. Regardless I would say that actually providing the correct string value to an interactive component that expects a string value seems like a rather good practice. Otherwise you will have two distinct value states and , but both being intended to mean the exact same thing. No, because being or makes it uncontrolled by definition and you shouldn't switch between controlled and uncontrolled.", "commid": "react_issue_5821", "tokennum": 422}], "negative_passages": []}
{"query_id": "q-en-react-61f145b3ab1da166c3b36c4f2447fbf632d0505e99e942cb338e005a517d7ad9", "query": "<ins> const React = window.React; import Fixture from '../../Fixture'; class NumberInputDecimal extends React.Component { state = { value: '.98' }; changeValue = () => { this.setState({ value: '0.98', }); } render() { const {value} = this.state; return ( <Fixture> <div>{this.props.children}</div> <div className=\"control-box\"> <input type=\"number\" value={value} onChange={(e) => { this.setState({value: e.target.value}); }} /> <button onClick={this.changeValue}>change.98 to 0.98</button> </div> </Fixture> ); } } export default NumberInputDecimal; </ins>", "positive_passages": [{"docid": "doc-en-react-a1ec312e283159f26e0810232ac577e1b491bd7a2e41ef77639a5a1a6e69ad7f", "text": "for example, when the original value is '.98', we need format it to '0.98'. but it is not take effect\nThis is working for me -\nyour example is not same with mine. the key is .98 can't be formated to 0.98. Because as number they are equal.\nJust housekeeping. Do we close out issues before a release with the fix has shipped or wait?\ntypically I close the issue once the has been merged into master\nAwesome, thanks! This should land in the next minor release of React:", "commid": "react_issue_9712", "tokennum": 114}], "negative_passages": []}
{"query_id": "q-en-react-629f2bae2515219f2a8988286eb5e10ea6b69e3b33a4375b0fb5c4b6a8168812", "query": "*/ import throttle from 'lodash.throttle'; <del> import { useCallback, useEffect, useLayoutEffect, useMemo, useState, } from 'react'; </del> <ins> import {useCallback, useEffect, useLayoutEffect, useState} from 'react'; </ins> import {unstable_batchedUpdates as batchedUpdates} from 'react-dom'; import { localStorageGetItem,", "positive_passages": [{"docid": "doc-en-react-473a4b58713ca7c8d0e8060a45651ad2625b8e108683a3fbb58f5695d87bc14b", "text": "Do you want to request a feature or report a bug? Report a bug What is the current behavior? The hook's value is shown as in React DevTools if the value is a string or a number. Clicking on the bug icon prints the correct values to console. ! If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. CodeSandbox: Direct link to page so you can see the DevTools: What is the expected behavior? The DevTools should show the correct value of the hook. Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React? React 16.9.0. Google Chrome [Version 77.0.3865.90 (Official Build) (64-bit)] running on Linux x64. This issue appeared after version 4.1.0 (9/19/2019) of the DevTools Chrome extension. Might be same bug as but this one appears without any complicated reproduction steps.\nLooks like the issue also appears with boolean values.\nHaving the same problem. The extension worked fine after I downgraded React to version 16.8.6\nI think the only significant difference between React v16.8 and v16.9 is that v16.9 injects the function DevTools uses to support editable hooks (in other words, DevTools is using a different code path when you run v16.8 vs v16.9). I think that means this bug is probably related to somehow. Will dig in more.\nShould be fixed by\nThis fix will be released with 4.1.1 (sometime soon)\nThis fix has just been published to NPM and posted to Chrome/Firefox as v4.1.1", "commid": "react_issue_16859", "tokennum": 400}], "negative_passages": []}
{"query_id": "q-en-react-62b87c43085c170f5af869c2956ac32ee733c1e2f3ba0cc686ec53e059925926", "query": "assign( ShallowComponentWrapper.prototype, ReactCompositeComponent.Mixin, { <ins> _constructComponent: ReactCompositeComponent.Mixin._constructComponentWithoutOwner, </ins> _instantiateReactComponent: function(element) { return new NoopInternalComponent(element); },", "positive_passages": [{"docid": "doc-en-react-ca19df289e02684e61e07a528776d59aafa3f9ae31aa0dfa1ca6abf5d058dfe3", "text": "There appears to have been a change in how is generated between 0.13 and 0.14 which is causing a number of our shallow rendered tests to fail when upgrading because the deepEquals fails on the property. Here is a simple example component which exhibits the issue.\nI've been seeing some similar issues with shallow rendering. My current (messy - sorry!) workaround is this: Let me know if that helps! My version currently breaks some of the Jest tests, but I'm happy to work on this some more and submit a PR.\nThank you very much for this, it's been a tremendous help! While this solved the problem for my test case above it still failed on a large number of our more complex tests. I've been iterating on it and once I have all of our tests passing I'll add the updated version.\nHere is the updated workaround, it works for our 238 tests of varying complexity but I'd be interested to see if it passes all of your tests as well.\nAwesome! If you don't mind trying, what happens if you do and then use the earlier ?\nMuch cleaner thanks, I guess I was in my head too much :)\nI prefer applying a monkey patch, until we have this fixed in react by wrapping TestUtils in my own module:\nThis should be fixed by .", "commid": "react_issue_5292", "tokennum": 278}], "negative_passages": []}
{"query_id": "q-en-react-64fda69ef058a0fb9761664fa37c4a8f83e35b49c000ec35276e35dc033f6876", "query": "hookSourceData.originalSourceAST = sourceMetadata.originalSourceAST; hookSourceData.originalSourceCode = sourceMetadata.originalSourceCode; } else { <ins> // TypeScript is the most commonly used typed JS variant so let's default to it // unless we detect explicit Flow usage via the \"@flow\" pragma. const plugin = originalSourceCode.indexOf('@flow') > 0 ? 'flow' : 'typescript'; </ins> // TODO (named hooks) Parsing should ideally be done off of the main thread. const originalSourceAST = parse(originalSourceCode, { sourceType: 'unambiguous', <del> plugins: ['jsx', 'typescript'], </del> <ins> plugins: ['jsx', plugin], </ins> }); hookSourceData.originalSourceAST = originalSourceAST; if (__DEBUG__) {", "positive_passages": [{"docid": "doc-en-react-bcec4924c65bed9eaf4f2164420d72977dc52095a7bc3aca95abe7e231d936e6", "text": "DevTools tells Babel to parse the source code using \"jsx\" and \"typescript\" plug-ins: This will work for some simple usages of Flow, but syntax may diverge and cause the parsing to fail. Let's scan the source code for a pragma and pass \"flow\" instead of \"typescript\" if one is found. We should also add tests for both Flow and TypeScript to the test component pool:\nI think something as basic as this should work:", "commid": "react_issue_21793", "tokennum": 106}], "negative_passages": []}
{"query_id": "q-en-react-66da6191bbac8814b5e9666d30d45da137b3e0958753238084670324181fac75", "query": "if (__DEV__) { warnIfValueIsNull(props); <ins> var initialValue = inst._wrapperState.initialChecked || inst._wrapperState.initialValue; var defaultValue = props.defaultChecked || props.defaultValue; var controlled = props.checked !== undefined || props.value !== undefined; var owner = inst._currentElement._owner; if ( (initialValue || !inst._wrapperState.controlled) && controlled && !didWarnUncontrolledToControlled ) { warning( false, '%s is changing a uncontrolled input of type %s to be controlled. ' + 'Input elements should not switch from uncontrolled to controlled (or viceversa). ' + 'Decide between using a controlled or uncontrolled input ' + 'element for the lifetime of the component. More info: https://fb.me/react-controlled-components', owner && owner.getName() || 'A component', props.type ); didWarnUncontrolledToControlled = true; } if ( inst._wrapperState.controlled && (defaultValue || !controlled) && !didWarnControlledToUncontrolled ) { warning( false, '%s is changing a controlled input of type %s to be uncontrolled. ' + 'Input elements should not switch from controlled to uncontrolled (or viceversa). ' + 'Decide between using a controlled or uncontrolled input ' + 'element for the lifetime of the component. More info: https://fb.me/react-controlled-components', owner && owner.getName() || 'A component', props.type ); didWarnControlledToUncontrolled = true; } </ins> } // TODO: Shouldn't this be getChecked(props)?", "positive_passages": [{"docid": "doc-en-react-2d50644914e10b5751903bb65355dc5f5ba6e3cbb7af72fb79c683173a5cbe53", "text": "A component should either be using uncontrolled inputs or controlled inputs, but not both (they should pick a single paradigm, for the lifetime of the component). As a result, an instance of an input should never switch from controlled to uncontrolled (or vice versa). We should warn when an input that was previously controlled becomes uncontrolled, or vice versa.\nCould you provide some code as to how a controlled input becomes uncontrolled and vice versa?\nI just got this warning, can anyone point me to an explanation with a bit more detail? ty\nput your code in a stackoverflow question, and link it here.\nnewswim Read about controlled components and uncontrolled components. Choose one (preferably controlled components), and don't ever use uncontrolled components. If you are using controlled components, make sure you never pass a or to React. And yes, is correct, this is better addressed on StackOverflow.\nI don't consider an input's value being null or undefined as a qualifying factor in determining if an input is controlled or uncontrolled. Controlled forms are a paradigm that may share some qualities with uncontrolled forms. It's about listening to changes and updating the state of the value, but React shouldn't stipulate that the value can't be undefined. It's an additional burden to those following good practice in using controlled forms. This warning should occur if both defaultValue and value props are used throughout the input's lifecycle.\nI agree, but in the sense that they shouldn't be a single component at all, they should be two separate. Regardless I would say that actually providing the correct string value to an interactive component that expects a string value seems like a rather good practice. Otherwise you will have two distinct value states and , but both being intended to mean the exact same thing. No, because being or makes it uncontrolled by definition and you shouldn't switch between controlled and uncontrolled.", "commid": "react_issue_5821", "tokennum": 422}], "negative_passages": []}
{"query_id": "q-en-react-69ea2b9c8c126cc114c69938a50120f37931a1ceb54001bf90d024e380581db0", "query": "return this.refs.anch; }, render: function() { <del> var className = cx({'anchorClass': this.props.anchorClassOn}); </del> <ins> var className = this.props.anchorClassOn ? 'anchorClass' : ''; </ins> return this.props.renderAnchor ? <a ref=\"anch\" className={className}></a> : <b></b>;", "positive_passages": [{"docid": "doc-en-react-a25328977cbf76bc3b508d745231e0aa56e3f7d590ad2f7ceaf276e749ebae16", "text": "This has no dependencies so I think we should either publish it as a standalone module or direct people to something else from the community. I'm inclined to do the latter since it means we can wash our hands of it. Our internal usage of is tied to our transforms so we've said no to features that would be useful to others outside FB. I'm concerned we'd do that again. Any suggestions for existing projects that we can point to?\nCan't we just link to a bunch of \"useful scripts\" in the docs and leave it at that? People are free to use/modify them, it's implied they're not being maintained and are there just for getting people started. I feel like a lot of people don't understand the current state of , but expect them to be full-blown frameworks and updated with every feature conceivable. Publishing on NPM kind of continues that trend and I suspect no-one on Team React really cares about the addons enough. So I would say, make them available in the docs (as code/files) and let the community sort out publishing/improving/direction.\n...Can I \"steal\" the code and post it somewhere else under my name? I do need it for another CSS repo of mine, and it's really not React-specific.\nAfter talking with Jed at the conference, I think I'll just point people at\nPete hunt already has react-classset module on npm I believe as well\nAccording to the react-classset has been deprecated in favor of the above mentioned library.\nIt is. They're pretty much the same except for some negligible differences so I deprecated the former (the latter has an active maintainer).", "commid": "react_issue_2910", "tokennum": 368}], "negative_passages": []}
{"query_id": "q-en-react-6af9c9ac80c36e79884e6f136139b9e2d2c79a3d34bbe49bb089df5eda3f64f8", "query": "} effect = effect.nextEffect; } while (effect !== null); <ins> if (__DEV__) { resetCurrentFiber(); } </ins> isRendering = previousIsRendering;", "positive_passages": [{"docid": "doc-en-react-32fed7447c33e1c49292377f28ba22b1f003566fcb0c01f418bb8b8e131f1319", "text": "I've noticed a strange bug with the react redux opt-in. If i use it with a connected class component, everything is ok: If i use it with a connected functional component that use with , i obtain a strange error: in method. I create a codepen to reproduce the issue: PS: Sorry for the cors error, but i don't find the way to add as cdn\nI believe the issue here is that expects the second argument to be a function that returns the reference: See: for more information about the API of the hook. Maybe the error thrown could be more clear?\nYou're right, accept a function as second argument. A warning on wrong argument type could be a good idea.\nIll take this issue on\nSure\ni get TypeError: React.useImperativeMethods is not a function in 16.8.0-alpha.1 but when back to 16.7.0-alpha.2 not get this error\nThe hook was renamed in this PR: Most likely between the 16.7 alpha and 16.8 alpha\nYeah, it was renamed.\nyes it work good after rename it where i can get changes between alpha version ?\nCommit log. We don't write changelogs for alphas.\nI'm taking this in since we want to get Hooks out sooner.\nalright np", "commid": "react_issue_14629", "tokennum": 277}], "negative_passages": []}
{"query_id": "q-en-react-6c96477edc04d8ccf811044b5c114672baa03bbd04571699ae1b72f737387ae0", "query": "\"node\": \">=0.10.0\" }, \"peerDependencies\": { <del> \"envify\": \"~1.0.1\" </del> <ins> \"envify\": \"~1.2.0\" </ins> }, \"browserify\": { \"transform\": [\"envify\"]", "positive_passages": [{"docid": "doc-en-react-832461d1f72ff21d99d4083f935ce25899a30aae17475b0c8a67c7f1b0380ed5", "text": "React 0.8 React 0.9 I think this is because of switched to in 1.0.0. I submitted a to envify which uses instead of recast. This brings us back to 1.5s and delivers the same advantages as recast version (preserves code formatting): I think this is blocker for 0.9.0.\nWhat command are you running, and in what directory? I'm having trouble reproducing the slow-down with just .", "commid": "react_issue_1108", "tokennum": 102}], "negative_passages": []}
{"query_id": "q-en-react-6d7efc2d7e5693dc32926e539a51b1f288ada36a93d0b3cbcee04388e298e1c1", "query": "<ins> name: DevTools Check for bug repro on: issues: types: [opened, edited] issue_comment: types: [created, edited] jobs: check-repro: runs-on: ubuntu-latest steps: - uses: actions/github-script@v3 with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | const URL_REGEXP = /### Website or app[rn]+([^#]+)###/m; const REPRO_STEPS_REGEXP = /### Repro steps[rn]+([^#]+)###/m; const LABEL_NEEDS_MORE_INFORMATION = \"Resolution: Needs More Information\"; const LABEL_UNCONFIRMED = \"Status: Unconfirmed\"; function debug(...args) { core.info(args.map(JSON.stringify).join(' ')); } if (context.payload.comment) { debug('Ignoring comment update.'); return; } const user = context.payload.sender.login; const issue = context.payload.issue; const body = issue.body; const urlMatch = body.match(URL_REGEXP); const reproStepsMatch = body.match(REPRO_STEPS_REGEXP); const url = urlMatch !== null ? urlMatch[1].trim() : null; const reproSteps = reproStepsMatch !== null ? reproStepsMatch[1].trim() : null; if (!url || !reproSteps) { debug('This issue is not a DevTools bug report.'); return; } debug(`found URL \"${url}\"`); debug(`found repro steps \"${reproSteps}\"`); function formatComment(comment) { return comment .split(\"n\") .map((line) => line.trim()) .join(\"n\") .trim(); } async function getGitHubActionComments() { debug(`Loading existing comments...`); const comments = await github.issues.listComments({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, }); return comments.data.filter(comment => { debug(`comment by user: \"${comment.user.login}\"`); return comment.user.login === 'github-actions[bot]'; }); } async function getIssueLabels() { const issues = await github.issues.listLabelsOnIssue({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, }); return issues.data; } async function closeWithComment(comment) { if (issue.state !== 'open') { debug(`Issue is not open`); return; } const labels = await getIssueLabels(); const label = labels.find(label => label.name === LABEL_UNCONFIRMED); if (!label) { debug(`Issue was not opened via DevTools bug report template`); return; } const comments = await getGitHubActionComments(); if (comments.length > 0) { debug(`Already commented on issue; won't comment again`); return; } debug(`Missing required information`); await github.issues.addLabels({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, labels: [LABEL_NEEDS_MORE_INFORMATION], }); await github.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, body: formatComment(comment), }); await github.issues.update({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, state: 'closed', }); } async function openWithComment(comment) { if (issue.state !== 'closed') { debug(`Issue is already open`); return; } const labels = await getIssueLabels(); const label = labels.find(label => label.name === LABEL_NEEDS_MORE_INFORMATION); if (!label) { debug(`Issue was not tagged as needs information`); return; } const comments = await getGitHubActionComments(); if (comments.length === 0) { debug(`Issue was closed by someone else; won't reopen`); return; } debug(`Re-opening closed issue`); await github.issues.removeLabel({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, name: LABEL_NEEDS_MORE_INFORMATION, }); await github.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, body: formatComment(comment), }); await github.issues.update({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, state: 'open', }); } const PROBABLY_NOT_A_URL_REGEX = /(^Chrome$|^Firefox$| Website)/i; const COMMENT_HEADER = ` @${user}: We're sorry you've seen this error. \u2764\ufe0f `.trim(); const COMMENT_FOOTER = ` Please help us by providing a link to a CodeSandbox (https://codesandbox.io/s/new), a repository on GitHub, or a minimal code example that reproduces the problem. (Screenshots or videos can also be helpful if they help provide context on how to repro the bug.) Here are some tips for providing a minimal example: https://stackoverflow.com/help/mcve Issues without repros are automatically closed but we will re-open if you update with repro info. `.trim(); if (url.includes(\"/localhost\")) { closeWithComment(` ${COMMENT_HEADER} Unfortunately the URL you provided (\"localhost\") is not publicly accessible. (This means that we will not be able to reproduce the problem you're reporting.) ${COMMENT_FOOTER} `); } else if (url.length < 10 || url.match(PROBABLY_NOT_A_URL_REGEX)) { closeWithComment(` ${COMMENT_HEADER} It looks like you forgot to specify a valid URL. (This means that we will not be able to reproduce the problem you're reporting.) ${COMMENT_FOOTER} `); } else if (reproSteps.length < 25) { closeWithComment(` ${COMMENT_HEADER} Unfortunately, it doesn't look like this issue has enough info for one of us to reproduce and fix it though. ${COMMENT_FOOTER} `); } else { openWithComment(` Thank you for providing repro steps! Re-opening issue now for triage. `); } </ins>", "positive_passages": [{"docid": "doc-en-react-a9430f1b4acf3a38befd950f7bd1a8df5b8a87bbc5ded6086aacb71a782df8a6", "text": "Many of the issues created with the with the template are missing repro information (e.g. a \"localhost\" or otherwise invalid URL, missing or no repro description). I usually have to review, label, comment, and close this by hand. It would be nice if we had an automated action that checked: Was the issue made with the template? Does the URL section have an invalid URL (e.g. \"localhost\" or \"company website\") Does the repro steps section have invalid steps (e.g. \"don't know\") For issues that pass all of the above text, the bot should: Assign the \"Resolution: Needs More Information\" label Close the issue Leave a comment explaining that repro information was missing and that we'll re-open it if information is provided\nRelated action:\nGoing to play with this idea here:", "commid": "react_issue_21541", "tokennum": 185}], "negative_passages": []}
{"query_id": "q-en-react-6e3497be782356eca9011a06a8cd1c87499f85f6464b0bdc794757dfabda927b", "query": "form: MUST_USE_ATTRIBUTE, formNoValidate: HAS_BOOLEAN_VALUE, frameBorder: MUST_USE_ATTRIBUTE, <ins> headers: null, </ins> height: MUST_USE_ATTRIBUTE, hidden: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE, href: null,", "positive_passages": [{"docid": "doc-en-react-16680cd16785bd149ce8f71ec27813f47ce0e569c64f71f4fc951f60d8a8becc", "text": "I am working on a project that has strict accessibility requirements. The table I am putting some data in has to implement headers and ids attributes to meet accessibility. See W3 techniques here Unfortunately the \"headers\" attribute is being stripped out because it's not supported by React (it's not on the supported attributes list). Can you please add support for the missing standard attribute called \"headers\"?\n+1\nAs a workaround I believe on a you can grab the DOMNode with a ref and add what you need.", "commid": "react_issue_2516", "tokennum": 111}], "negative_passages": []}
{"query_id": "q-en-react-6fce99540fe2507e709fc7d4026e8b8ac6c9e78ed3b146299a2c5e136f2c2688", "query": "override: - ./scripts/circleci/test_entry_point.sh: parallel: true <del> deployment: staging: branch: /.*/ commands: - ./scripts/circleci/upload_build.sh </del>", "positive_passages": [{"docid": "doc-en-react-d8ee1ccb8399f810362f1a0abd267e8242d6b55ced92ad6d4ce964cd672b1c32", "text": "It looks like this: It happened two times on random commits, and I don't see a pattern. Probably caused by me changing how tasks are distributed between parallel nodes in I don't understand why would try to run before a build exists though (if that's what's happening?)\nI think this one would require some experience with CircleCI. I don't have any pointers as to where to start: I don't understand why it's failing myself. So it's not a very beginner-friendly issue (I marked the difficulty as medium for that reason).\nAnother example:\nI want to work on this. After doing some research on circleci document, I didn't find the document said about parallel test and deployment sequence. I'm curious about how circleci deal with parallel test and deployment sequence. I think there are two situations: all parallel test finishes, run deployment sequence. If this is true, I think it won't cause current test error. container runs deployment after the container's test finished. I guess it is more likely in this case. Sometimes it passed, it's because node 2 already built file. Sometimes it failed because node 2 didn't build file yet. So I think maybe that's because each container will run deployment after that node test finished. If the situation is as above, I come up with two solutions. we want to keep current test flow, we can try to keep each node builds time balance. this test at first, then run other test parallel. reference link:\nOnly node 2 does a full build. So I don't understand how deployment on other nodes could work at all.\nOr do nodes share the file system?\nI think nodes share the file system. Otherwise, it should fail every time. It will be easier to debug if we can add more log, like current build time and .\nWould it make sense to change the upload script to only run on the second node?\nYep, I think so, because in the document I can't ensure whether deployment stage is triggered after all parallel test finished.\nCan we just put the deployment command right into the test command? Is there any benefit to separating them?\nI think it's also workable, but may lead misunderstanding. Cause we put build process to test stage. Or we can try to use stage. Run at compile stage, so we can promise and stages have needed file.", "commid": "react_issue_11657", "tokennum": 500}], "negative_passages": []}
{"query_id": "q-en-react-6fce99540fe2507e709fc7d4026e8b8ac6c9e78ed3b146299a2c5e136f2c2688", "query": "override: - ./scripts/circleci/test_entry_point.sh: parallel: true <del> deployment: staging: branch: /.*/ commands: - ./scripts/circleci/upload_build.sh </del>", "positive_passages": [{"docid": "doc-en-react-e735e4bcc04de4af8c79e9b836d6bd97863c094232bf2c644c6a4d2b1d364c3b", "text": "The interesting part is our regular tests don't need compilation. If \"compile\" stage has to run before any other stages then we'll wait unnecessarily. I'd prefer to have a single script that does everything than to buy into CircleCI specific terminology unless it buys us something real good (e.g. parallelism was very useful). Maybe can try this:\nOK, I understand your consideration. I think this fix will work. Just tell me if anything can help.", "commid": "react_issue_11657", "tokennum": 103}], "negative_passages": []}
{"query_id": "q-en-react-72577d740fc290177bb7e5adeeb330919d60705f76653a48804ee839b8149780", "query": "workInProgress: Fiber, priorityLevel: PriorityLevel, ): void { <ins> if (__DEV__) { checkClassInstance(workInProgress); } </ins> const instance = workInProgress.stateNode; const state = instance.state || null;", "positive_passages": [{"docid": "doc-en-react-a67bb8376120b6e82f0ec7816daa64a33d39d6f140cc4daae8de19fe914fffd1", "text": "Follow up from Here's one I found. These two invariants: are in a function that's behind a DEV block: I don't think this is intentional, but need to verify. There may be more. I'll use this issue to track while preserves existing behavior.\nHere\u2019s another difference: in development, putting a string ref on a functional component throws with: Stateless function components cannot have refs. but in production gives you: Element ref was specified as a string but no owner was set.", "commid": "react_issue_11618", "tokennum": 107}], "negative_passages": []}
{"query_id": "q-en-react-742257d9fdf00fe5542365d2d213b494254075b95cbdf3c8ff69d0774e53a57c", "query": "<ins> --- layout: none --- <?xml version=\"1.0\" encoding=\"UTF-8\"?> <rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\"> <channel> <title>{{ site.name }}</title> <description>{{ site.description }}</description> <link>{{ site.url }}{{ site.baseurl }}</link> <atom:link href=\"{{ site.url }}{{ site.baseurl }}/feed.xml\" rel=\"self\" type=\"application/rss+xml\" /> {% for post in site.posts limit:10 %} <item> <title>{{ post.title | xml_escape }}</title> <description>{{ post.content | xml_escape }}</description> <pubDate>{{ post.date | date_to_xmlschema }}</pubDate> <link>{{ site.url }}{{ site.baseurl }}{{ post.url }}</link> <guid isPermaLink=\"true\">{{ site.url }}{{ site.baseurl }}{{ post.url }}</guid> </item> {% endfor %} </channel> </rss> </ins>", "positive_passages": [{"docid": "doc-en-react-0096013fb4cf0b8fdc3e43b92829e482b2e25e28b443871d5fa8617b278878ee", "text": "As it is known (but ), React's SyntheticEvent is pooled. This is confusing for many users as they don't understand why the event starts to behave strangely when used in an async callback, like inside a , a or a callback. There has already been an attempt to solve this problem here: The code of SyntheticEvent's default methods is: It may make sense to be more defensive because calling on a pooled event will raise . It would be more useful to add a check like:\nTo illustrate the problem in not being defensive, I would give you this commit that has made it into production as a workaround in React-tappable: Basically the user is trying to assign an empty function to a SyntheticEvent that as been put back in the pool (the call to persist was from another PR at the same time). And we were basically 3 concurrent PR to try different solutions to the exact same problem.\nAs the person who made the PR in a panic, I did find the code that broke in react itself. the preventDefault method tries to call the method on . A simple if check for in the method, and a no-op if null would be a great fix to this problem. Similar to how setState is handled on an unmounted component.\nI think React should not swallow this error and be fail fast, because this does not make any sense to preventDefault in an async callback (because the default already has been applied), React should rather throw an error. But this is only my opinion, because the browser behavior with dom events is not fail fast and swallow that bad usage of preventDefault. I mean the browser does not throw an error when we do: It simply has no effect (like what you suggest) I don't like this and would rather change the behavior of both React and the browser, but I don't think I can do much on my own... Maybe at least React could issue a warning in DEV env?\nYeah, I think warning is appropriate here.\nA warning would be great!\nJust wonder what kind of message should be put into this warning. If event pooling is not going to be documented (will it?), it may be strange to explain the pooling system inside a warning no?\nYes, event pooling should/will be documented. Feel free to submit a PR. We should add a warning to let the user know that the event has been returned to the pool and so invoking methods on it makes no sense.", "commid": "react_issue_4514", "tokennum": 527}], "negative_passages": []}
{"query_id": "q-en-react-742257d9fdf00fe5542365d2d213b494254075b95cbdf3c8ff69d0774e53a57c", "query": "<ins> --- layout: none --- <?xml version=\"1.0\" encoding=\"UTF-8\"?> <rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\"> <channel> <title>{{ site.name }}</title> <description>{{ site.description }}</description> <link>{{ site.url }}{{ site.baseurl }}</link> <atom:link href=\"{{ site.url }}{{ site.baseurl }}/feed.xml\" rel=\"self\" type=\"application/rss+xml\" /> {% for post in site.posts limit:10 %} <item> <title>{{ post.title | xml_escape }}</title> <description>{{ post.content | xml_escape }}</description> <pubDate>{{ post.date | date_to_xmlschema }}</pubDate> <link>{{ site.url }}{{ site.baseurl }}{{ post.url }}</link> <guid isPermaLink=\"true\">{{ site.url }}{{ site.baseurl }}{{ post.url }}</guid> </item> {% endfor %} </channel> </rss> </ins>", "positive_passages": [{"docid": "doc-en-react-a921f1409d3df9aa98ff285bf83b4494772cc9ad53fb31860c5c3a2f4b8d23cf", "text": "Once the docs are written, we can add a link to the end of the warning.\nGot a PR for this! Would really appreciate some feedback.", "commid": "react_issue_4514", "tokennum": 31}], "negative_passages": []}
{"query_id": "q-en-react-78fd6b64b88a3c6c8369f852efab0b0789a8d90d184d63c629be6d9685e59d88", "query": "export function createCache(invalidator: () => mixed): Cache { const resourceMap: ResourceMap = new Map(); <del> function accessRecord<K, V>(resourceType: any, key: K): Record<V> { </del> <ins> function accessRecord<K, V>(resourceType: any, key: K): Record<K, V> { </ins> if (__DEV__) { warning( typeof resourceType !== 'string' && typeof resourceType !== 'number',", "positive_passages": [{"docid": "doc-en-react-6b3c5af2ada23f47aa80eedc03ca3a83d950eba15ef87f3dd6836f67ab1f9949", "text": "In we landed a change to the Flow types in , making the types for the various types recursive with their and properties. On that PR we may have been running an older version of Flow - I'm not having luck finding the record of when Flow ran for that PR, so not sure. In any case, that PR was merged even though it had the recursive Flow type definitions, plus one or more Flow errors which were unrelated and not detected. The problem with the recursive type definitions is that recent versions of Flow will go into an infinite loop if they try to infer types which are recursive. The solution may be to add more detail to those types, but to unblock things we temporarily made them looser type definitions.", "commid": "react_issue_12941", "tokennum": 154}], "negative_passages": []}
{"query_id": "q-en-react-7caf4e4456c40c08e954ae9b6ef53241c0e0d73a33dcd7ccac6cdfd5af08020f", "query": "* @param [string ...] Variable list of classNames in the string case. * @return string Renderable space-separated CSS className. */ <ins> 'use strict'; var warning = require('warning'); var warned = false; </ins> function cx(classNames) { <ins> if (__DEV__) { warning( warned, 'React.addons.classSet will be deprecated in a future version. See ' + 'http://fb.me/react-addons-classset' ); warned = true; } </ins> if (typeof classNames == 'object') { return Object.keys(classNames).filter(function(className) { return classNames[className];", "positive_passages": [{"docid": "doc-en-react-a25328977cbf76bc3b508d745231e0aa56e3f7d590ad2f7ceaf276e749ebae16", "text": "This has no dependencies so I think we should either publish it as a standalone module or direct people to something else from the community. I'm inclined to do the latter since it means we can wash our hands of it. Our internal usage of is tied to our transforms so we've said no to features that would be useful to others outside FB. I'm concerned we'd do that again. Any suggestions for existing projects that we can point to?\nCan't we just link to a bunch of \"useful scripts\" in the docs and leave it at that? People are free to use/modify them, it's implied they're not being maintained and are there just for getting people started. I feel like a lot of people don't understand the current state of , but expect them to be full-blown frameworks and updated with every feature conceivable. Publishing on NPM kind of continues that trend and I suspect no-one on Team React really cares about the addons enough. So I would say, make them available in the docs (as code/files) and let the community sort out publishing/improving/direction.\n...Can I \"steal\" the code and post it somewhere else under my name? I do need it for another CSS repo of mine, and it's really not React-specific.\nAfter talking with Jed at the conference, I think I'll just point people at\nPete hunt already has react-classset module on npm I believe as well\nAccording to the react-classset has been deprecated in favor of the above mentioned library.\nIt is. They're pretty much the same except for some negligible differences so I deprecated the former (the latter has an active maintainer).", "commid": "react_issue_2910", "tokennum": 368}], "negative_passages": []}
{"query_id": "q-en-react-7dc7a35ee6bbd0b5ab9b398962b134075cba411420398775f54f389be456d4e5", "query": "); }); <ins> it('should not enumerate enumerable numbers (#4776)', function() { /*eslint-disable no-extend-native */ Number.prototype['@@iterator'] = function() { throw new Error('number iterator called'); }; /*eslint-enable no-extend-native */ try { var instance = ( <div> {5} {12} {13} </div> ); var traverseFn = jasmine.createSpy(); traverseAllChildren(instance.props.children, traverseFn, null); expect(traverseFn.calls.length).toBe(3); expect(traverseFn).toHaveBeenCalledWith( null, 5, '.0' ); expect(traverseFn).toHaveBeenCalledWith( null, 12, '.1' ); expect(traverseFn).toHaveBeenCalledWith( null, 13, '.2' ); } finally { delete Number.prototype['@@iterator']; } }); </ins> });", "positive_passages": [{"docid": "doc-en-react-e67de791693db938af10b78c2ee6743684ef35b812d1374870cdb39182ae80b2", "text": "Issue with the reproducible example . Full build contains non-standard iterator. Theoretical, it can be to ES in the future, it can be (or already ) to another libraries. should take into account possibility iterable numbers.\nWell, the good news is that if this is already on enough pages, then introducing iterable numbers may not be web compatible anyway. I think that this is only in DEV only code. Unfortunately a lot of pages incorrectly uses the DEV build of React.\n\"good news\"", "commid": "react_issue_4776", "tokennum": 106}], "negative_passages": []}
{"query_id": "q-en-react-82fb1ad4d26546d89090af49450fd3359c55089d151b9211925e07b0a04b5e5f", "query": "<ins> /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * * @emails react-core */ 'use strict'; var React; var ReactDOM; var ReactTestUtils; describe('ReactEventIndependence', function() { beforeEach(function() { require('mock-modules').dumpCache(); React = require('React'); ReactDOM = require('ReactDOM'); ReactTestUtils = require('ReactTestUtils'); }); it('does not crash with other react inside', function() { var clicks = 0; var div = ReactTestUtils.renderIntoDocument( <div onClick={() => clicks++} dangerouslySetInnerHTML={{ __html: '<button data-reactid=\".z\">click me</div>', }} /> ); ReactTestUtils.SimulateNative.click(div.firstChild); expect(clicks).toBe(1); }); it('does not crash with other react outside', function() { var clicks = 0; var outer = document.createElement('div'); outer.setAttribute('data-reactid', '.z'); var inner = ReactDOM.render( <button onClick={() => clicks++}>click me</button>, outer ); ReactTestUtils.SimulateNative.click(inner); expect(clicks).toBe(1); }); it('does not when event fired on unmounted tree', function() { var clicks = 0; var container = document.createElement('div'); var button = ReactDOM.render( <button onClick={() => clicks++}>click me</button>, container ); // Now we unmount the component, as if caused by a non-React event handler // for the same click we're about to simulate, like closing a layer: ReactDOM.unmountComponentAtNode(container); ReactTestUtils.SimulateNative.click(button); // Since the tree is unmounted, we don't dispatch the click event. expect(clicks).toBe(0); }); }); </ins>", "positive_passages": [{"docid": "doc-en-react-6746ac08815bbf89a554f2599c24efc7ee4f226755f4ae042a57183292a2342c", "text": "Since upgrading from beta3 to rc1 I've seen this error a few times in production. Haven't been able to trace the source yet though. cc\nI was unmounting a root during a keyboard event which caused this to happen. I think this has always been a problem? Perhaps we've only been lucky... leaving open just to be sure. EDIT: Could it make sense to have something along the lines of ? Allowing you to schedule things to occur as soon as the current transaction ends.\nThis invariant was new in this release. We also hit one case at FB that I haven't yet investigated. Probably need to change something for the final release.\nI have seen this on RC1 can't find a sequence of actions to repeat it.\nI'm running into this issue as well when conditionally rendering based on state. Not sure how to boil it down to a simple reproducible bug report yet.\nMy issue only happens when I am leveraging FastClick. Didn't happen before 0.14.\nI've found it is because the events are handled in a different order with fastclick, so the batching gets weird...\ne.g. click gets fired before touchEnd, so click handler setState to remove subtree, and then react tries to do something with it in touch end perhaps?", "commid": "react_issue_4865", "tokennum": 278}], "negative_passages": []}
{"query_id": "q-en-react-82fb1ad4d26546d89090af49450fd3359c55089d151b9211925e07b0a04b5e5f", "query": "<ins> /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * * @emails react-core */ 'use strict'; var React; var ReactDOM; var ReactTestUtils; describe('ReactEventIndependence', function() { beforeEach(function() { require('mock-modules').dumpCache(); React = require('React'); ReactDOM = require('ReactDOM'); ReactTestUtils = require('ReactTestUtils'); }); it('does not crash with other react inside', function() { var clicks = 0; var div = ReactTestUtils.renderIntoDocument( <div onClick={() => clicks++} dangerouslySetInnerHTML={{ __html: '<button data-reactid=\".z\">click me</div>', }} /> ); ReactTestUtils.SimulateNative.click(div.firstChild); expect(clicks).toBe(1); }); it('does not crash with other react outside', function() { var clicks = 0; var outer = document.createElement('div'); outer.setAttribute('data-reactid', '.z'); var inner = ReactDOM.render( <button onClick={() => clicks++}>click me</button>, outer ); ReactTestUtils.SimulateNative.click(inner); expect(clicks).toBe(1); }); it('does not when event fired on unmounted tree', function() { var clicks = 0; var container = document.createElement('div'); var button = ReactDOM.render( <button onClick={() => clicks++}>click me</button>, container ); // Now we unmount the component, as if caused by a non-React event handler // for the same click we're about to simulate, like closing a layer: ReactDOM.unmountComponentAtNode(container); ReactTestUtils.SimulateNative.click(button); // Since the tree is unmounted, we don't dispatch the click event. expect(clicks).toBe(0); }); }); </ins>", "positive_passages": [{"docid": "doc-en-react-19961fc470123ba131df0c13acdc16dca9ae2f0bc85b5a2da9d0662a1783f6d5", "text": "In this repro, I created 2 buttons and only one is rendered at a time. One button's click handler is hooked up to React's synthetic \"click\" event while the other is hooked up to the native \"click\" event. Even though only one button is rendered at a time, a single click is triggering both click events. This bug can be hit by apps that mix React components with non-React controls (e.g. jQuery UI). I reproed this in Chrome with React 0.13.2. to the button labeled \"One\" Expected: There's a button rendered labeled \"Two\" Actual: The rendered button still has the label \"One\" If you open the console, you'll see \"goToTwo\" and \"goToOne\" which indicates that the \"One\" button's click handler ran and then the \"Two\" button's click handler ran (even though we never saw button \"Two\"\").\nI experimented more and came up with another repro: In this one, you click on a button with a native \"click\" handler which causes the button to go away and an input field to be rendered. It results in this exception: From these 2 repros, it seems something strange is going on when calling from within a native \"click\" handler.\nIt works if you add to the event handler.\nThanks for the workaround. Is the behavior without the by design? It looks like the bad behavior is being caused by the rerender happening synchronously within the native \"click\" handler.\nThis looks bad. We don't do a great job interacting with native events. Sebastian wrote a post about this once-upon-a-time, how native and synthetic event systems are, by and large, not interoperable. Even so, I can't see a reason we should fatal like this. Do you understand what's going wrong here? What a fix might look like?\nThis happens when we handle a click event from a node that's been removed in between when the event is triggered and when React receives it. How should we deal with the case that events fire on detached elements? Should we ignore events for nodes that aren't in the document? I don't think the bug is easily fixable otherwise because we don't have the old event handler after the reconcile that removes that node.\nHere are some additional details about the impact of the bug.", "commid": "react_issue_3790", "tokennum": 505}], "negative_passages": []}
{"query_id": "q-en-react-82fb1ad4d26546d89090af49450fd3359c55089d151b9211925e07b0a04b5e5f", "query": "<ins> /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * * @emails react-core */ 'use strict'; var React; var ReactDOM; var ReactTestUtils; describe('ReactEventIndependence', function() { beforeEach(function() { require('mock-modules').dumpCache(); React = require('React'); ReactDOM = require('ReactDOM'); ReactTestUtils = require('ReactTestUtils'); }); it('does not crash with other react inside', function() { var clicks = 0; var div = ReactTestUtils.renderIntoDocument( <div onClick={() => clicks++} dangerouslySetInnerHTML={{ __html: '<button data-reactid=\".z\">click me</div>', }} /> ); ReactTestUtils.SimulateNative.click(div.firstChild); expect(clicks).toBe(1); }); it('does not crash with other react outside', function() { var clicks = 0; var outer = document.createElement('div'); outer.setAttribute('data-reactid', '.z'); var inner = ReactDOM.render( <button onClick={() => clicks++}>click me</button>, outer ); ReactTestUtils.SimulateNative.click(inner); expect(clicks).toBe(1); }); it('does not when event fired on unmounted tree', function() { var clicks = 0; var container = document.createElement('div'); var button = ReactDOM.render( <button onClick={() => clicks++}>click me</button>, container ); // Now we unmount the component, as if caused by a non-React event handler // for the same click we're about to simulate, like closing a layer: ReactDOM.unmountComponentAtNode(container); ReactTestUtils.SimulateNative.click(button); // Since the tree is unmounted, we don't dispatch the click event. expect(clicks).toBe(0); }); }); </ins>", "positive_passages": [{"docid": "doc-en-react-7851a482df6560c8b9755474dda32fba2e00952e4178b5bb7f60e2baae6ce704", "text": "It sounds like this bug is likely to trigger when you use a non-React component (e.g. jQuery UI) in a React single page application and the non-React component triggers a navigation within the app.\nThanks for an excellent bug report and good repro case! I think this happens because we use the \"root id\" to determine which element was clicked. In the repro case there is no \"key\" as part of the root ID for two reasons: 1) It is not a child of a container (multichild) so it doesn't get a key to the root ID. 2) It doesn't have a unique key and doesn't need one because it the button is of a different type. If I make sure that a key is used as part of the root ID the problem is solved: So the problem in the repro isn't that we're firing on a removed node, it is that we're firing the event on the new node. This would be solved if we used a unique ID per instance to identify event handlers instead of a generate root that is non-unique. Which I think we wanted to do anyway. Is there another repro that shows a different issue?", "commid": "react_issue_3790", "tokennum": 253}], "negative_passages": []}
{"query_id": "q-en-react-84484ad3445bd537ebd4e8016e4031fbabb99d6375bbfd8bb836f5638367c868", "query": "describe('ReactDOMComponent', function() { var React; var ReactDOM; <del> var ReactDOMFeatureFlags; </del> var ReactDOMServer; beforeEach(function() { jest.resetModuleRegistry(); React = require('React'); <del> ReactDOMFeatureFlags = require('ReactDOMFeatureFlags') </del> ReactDOM = require('ReactDOM'); ReactDOMServer = require('ReactDOMServer'); });", "positive_passages": [{"docid": "doc-en-react-02f66d4e335d6ddaefdaada0c5924337c1569646c887a9e0f46ffcf90b1e6c5d", "text": "Appears to be working in Firefox but at least Chrome & Safari are broken. Should be a really recent regression so very few possible changes to blame... Easiest repo: the todo list on our homepage.\nJust a heads up but this still seems to be an issue even on 15.4.1. I've been struggling to reproduce this because it seems to be some sort of ninja bug. Nevertheless, I was wondering if anyone is still dealing with this problem?\nI haven't seen anything.\nI'm still seeing this issue.\nPlease open a new issue with a simplified repro case if you're still seeing this!", "commid": "react_issue_6445", "tokennum": 133}], "negative_passages": []}
{"query_id": "q-en-react-84a7a3abb70646181d366d0a5d824819f632f0ab5a7930df3b6261d9aa212d25", "query": "- Gemfile.lock - README.md - Rakefile <ins> url: http://facebook.github.io </ins> baseurl: /react permalink: /blog/:year/:month/:day/:title.html", "positive_passages": [{"docid": "doc-en-react-0096013fb4cf0b8fdc3e43b92829e482b2e25e28b443871d5fa8617b278878ee", "text": "As it is known (but ), React's SyntheticEvent is pooled. This is confusing for many users as they don't understand why the event starts to behave strangely when used in an async callback, like inside a , a or a callback. There has already been an attempt to solve this problem here: The code of SyntheticEvent's default methods is: It may make sense to be more defensive because calling on a pooled event will raise . It would be more useful to add a check like:\nTo illustrate the problem in not being defensive, I would give you this commit that has made it into production as a workaround in React-tappable: Basically the user is trying to assign an empty function to a SyntheticEvent that as been put back in the pool (the call to persist was from another PR at the same time). And we were basically 3 concurrent PR to try different solutions to the exact same problem.\nAs the person who made the PR in a panic, I did find the code that broke in react itself. the preventDefault method tries to call the method on . A simple if check for in the method, and a no-op if null would be a great fix to this problem. Similar to how setState is handled on an unmounted component.\nI think React should not swallow this error and be fail fast, because this does not make any sense to preventDefault in an async callback (because the default already has been applied), React should rather throw an error. But this is only my opinion, because the browser behavior with dom events is not fail fast and swallow that bad usage of preventDefault. I mean the browser does not throw an error when we do: It simply has no effect (like what you suggest) I don't like this and would rather change the behavior of both React and the browser, but I don't think I can do much on my own... Maybe at least React could issue a warning in DEV env?\nYeah, I think warning is appropriate here.\nA warning would be great!\nJust wonder what kind of message should be put into this warning. If event pooling is not going to be documented (will it?), it may be strange to explain the pooling system inside a warning no?\nYes, event pooling should/will be documented. Feel free to submit a PR. We should add a warning to let the user know that the event has been returned to the pool and so invoking methods on it makes no sense.", "commid": "react_issue_4514", "tokennum": 527}], "negative_passages": []}
{"query_id": "q-en-react-84a7a3abb70646181d366d0a5d824819f632f0ab5a7930df3b6261d9aa212d25", "query": "- Gemfile.lock - README.md - Rakefile <ins> url: http://facebook.github.io </ins> baseurl: /react permalink: /blog/:year/:month/:day/:title.html", "positive_passages": [{"docid": "doc-en-react-a921f1409d3df9aa98ff285bf83b4494772cc9ad53fb31860c5c3a2f4b8d23cf", "text": "Once the docs are written, we can add a link to the end of the warning.\nGot a PR for this! Would really appreciate some feedback.", "commid": "react_issue_4514", "tokennum": 31}], "negative_passages": []}
{"query_id": "q-en-react-860df2ea2fb26adbbf66186efc91a81b51fc17fdec5d6e45768d01ac71438b82", "query": "expect(console.error.argsForCall.length).toBe(1); }); <ins> it('should warn if controlled input switches to uncontrolled', function() { var stub = <input type=\"text\" value=\"controlled\" onChange={emptyFunction} />; var container = document.createElement('div'); ReactDOM.render(stub, container); ReactDOM.render(<input type=\"text\" />, container); expect(console.error.argsForCall.length).toBe(1); expect(console.error.argsForCall[0][0]).toContain( 'A component is changing a controlled input of type text to be uncontrolled. ' + 'Input elements should not switch from controlled to uncontrolled (or viceversa). ' + 'Decide between using a controlled or uncontrolled input ' + 'element for the lifetime of the component. More info: https://fb.me/react-controlled-components' ); }); it('should warn if controlled input switches to uncontrolled with defaultValue', function() { var stub = <input type=\"text\" value=\"controlled\" onChange={emptyFunction} />; var container = document.createElement('div'); ReactDOM.render(stub, container); ReactDOM.render(<input type=\"text\" defaultValue=\"uncontrolled\" />, container); expect(console.error.argsForCall.length).toBe(1); expect(console.error.argsForCall[0][0]).toContain( 'A component is changing a controlled input of type text to be uncontrolled. ' + 'Input elements should not switch from controlled to uncontrolled (or viceversa). ' + 'Decide between using a controlled or uncontrolled input ' + 'element for the lifetime of the component. More info: https://fb.me/react-controlled-components' ); }); it('should warn if uncontrolled input switches to controlled', function() { var stub = <input type=\"text\" />; var container = document.createElement('div'); ReactDOM.render(stub, container); ReactDOM.render(<input type=\"text\" value=\"controlled\" />, container); expect(console.error.argsForCall.length).toBe(1); expect(console.error.argsForCall[0][0]).toContain( 'A component is changing a uncontrolled input of type text to be controlled. ' + 'Input elements should not switch from uncontrolled to controlled (or viceversa). ' + 'Decide between using a controlled or uncontrolled input ' + 'element for the lifetime of the component. More info: https://fb.me/react-controlled-components' ); }); it('should warn if controlled checkbox switches to uncontrolled', function() { var stub = <input type=\"checkbox\" checked={true} onChange={emptyFunction} />; var container = document.createElement('div'); ReactDOM.render(stub, container); ReactDOM.render(<input type=\"checkbox\" />, container); expect(console.error.argsForCall.length).toBe(1); expect(console.error.argsForCall[0][0]).toContain( 'A component is changing a controlled input of type checkbox to be uncontrolled. ' + 'Input elements should not switch from controlled to uncontrolled (or viceversa). ' + 'Decide between using a controlled or uncontrolled input ' + 'element for the lifetime of the component. More info: https://fb.me/react-controlled-components' ); }); it('should warn if controlled checkbox switches to uncontrolled with defaultChecked', function() { var stub = <input type=\"checkbox\" checked={true} onChange={emptyFunction} />; var container = document.createElement('div'); ReactDOM.render(stub, container); ReactDOM.render(<input type=\"checkbox\" defaultChecked={true} />, container); expect(console.error.argsForCall.length).toBe(1); expect(console.error.argsForCall[0][0]).toContain( 'A component is changing a controlled input of type checkbox to be uncontrolled. ' + 'Input elements should not switch from controlled to uncontrolled (or viceversa). ' + 'Decide between using a controlled or uncontrolled input ' + 'element for the lifetime of the component. More info: https://fb.me/react-controlled-components' ); }); it('should warn if uncontrolled checkbox switches to controlled', function() { var stub = <input type=\"checkbox\" />; var container = document.createElement('div'); ReactDOM.render(stub, container); ReactDOM.render(<input type=\"checkbox\" checked={true} />, container); expect(console.error.argsForCall.length).toBe(1); expect(console.error.argsForCall[0][0]).toContain( 'A component is changing a uncontrolled input of type checkbox to be controlled. ' + 'Input elements should not switch from uncontrolled to controlled (or viceversa). ' + 'Decide between using a controlled or uncontrolled input ' + 'element for the lifetime of the component. More info: https://fb.me/react-controlled-components' ); }); it('should warn if controlled radio switches to uncontrolled', function() { var stub = <input type=\"radio\" checked={true} onChange={emptyFunction} />; var container = document.createElement('div'); ReactDOM.render(stub, container); ReactDOM.render(<input type=\"radio\" />, container); expect(console.error.argsForCall.length).toBe(1); expect(console.error.argsForCall[0][0]).toContain( 'A component is changing a controlled input of type radio to be uncontrolled. ' + 'Input elements should not switch from controlled to uncontrolled (or viceversa). ' + 'Decide between using a controlled or uncontrolled input ' + 'element for the lifetime of the component. More info: https://fb.me/react-controlled-components' ); }); it('should warn if controlled radio switches to uncontrolled with defaultChecked', function() { var stub = <input type=\"radio\" checked={true} onChange={emptyFunction} />; var container = document.createElement('div'); ReactDOM.render(stub, container); ReactDOM.render(<input type=\"radio\" defaultChecked={true} />, container); expect(console.error.argsForCall.length).toBe(1); expect(console.error.argsForCall[0][0]).toContain( 'A component is changing a controlled input of type radio to be uncontrolled. ' + 'Input elements should not switch from controlled to uncontrolled (or viceversa). ' + 'Decide between using a controlled or uncontrolled input ' + 'element for the lifetime of the component. More info: https://fb.me/react-controlled-components' ); }); it('should warn if uncontrolled radio switches to controlled', function() { var stub = <input type=\"radio\" />; var container = document.createElement('div'); ReactDOM.render(stub, container); ReactDOM.render(<input type=\"radio\" checked={true} />, container); expect(console.error.argsForCall.length).toBe(1); expect(console.error.argsForCall[0][0]).toContain( 'A component is changing a uncontrolled input of type radio to be controlled. ' + 'Input elements should not switch from uncontrolled to controlled (or viceversa). ' + 'Decide between using a controlled or uncontrolled input ' + 'element for the lifetime of the component. More info: https://fb.me/react-controlled-components' ); }); </ins> it('sets type before value always', function() { var log = []; var originalCreateElement = document.createElement;", "positive_passages": [{"docid": "doc-en-react-2d50644914e10b5751903bb65355dc5f5ba6e3cbb7af72fb79c683173a5cbe53", "text": "A component should either be using uncontrolled inputs or controlled inputs, but not both (they should pick a single paradigm, for the lifetime of the component). As a result, an instance of an input should never switch from controlled to uncontrolled (or vice versa). We should warn when an input that was previously controlled becomes uncontrolled, or vice versa.\nCould you provide some code as to how a controlled input becomes uncontrolled and vice versa?\nI just got this warning, can anyone point me to an explanation with a bit more detail? ty\nput your code in a stackoverflow question, and link it here.\nnewswim Read about controlled components and uncontrolled components. Choose one (preferably controlled components), and don't ever use uncontrolled components. If you are using controlled components, make sure you never pass a or to React. And yes, is correct, this is better addressed on StackOverflow.\nI don't consider an input's value being null or undefined as a qualifying factor in determining if an input is controlled or uncontrolled. Controlled forms are a paradigm that may share some qualities with uncontrolled forms. It's about listening to changes and updating the state of the value, but React shouldn't stipulate that the value can't be undefined. It's an additional burden to those following good practice in using controlled forms. This warning should occur if both defaultValue and value props are used throughout the input's lifecycle.\nI agree, but in the sense that they shouldn't be a single component at all, they should be two separate. Regardless I would say that actually providing the correct string value to an interactive component that expects a string value seems like a rather good practice. Otherwise you will have two distinct value states and , but both being intended to mean the exact same thing. No, because being or makes it uncontrolled by definition and you shouldn't switch between controlled and uncontrolled.", "commid": "react_issue_5821", "tokennum": 422}], "negative_passages": []}
{"query_id": "q-en-react-959b0d37fd4cb58abebfcec76e769684d5d4d7a4e7e36df8993b9b7d4def009d", "query": "const [parsedValue, setParsedValue] = useState(initialValue); const [isValid, setIsValid] = useState(initialIsValid); <del> const reset = useCallback(() => { setEditableValue(smartStringify(initialValue)); setParsedValue(initialValue); setIsValid(initialIsValid); }, []); </del> <ins> const reset = useCallback( () => { setEditableValue(smartStringify(initialValue)); setParsedValue(initialValue); setIsValid(initialIsValid); }, [initialValue, initialIsValid], ); </ins> const update = useCallback(newValue => { let isNewValueValid = false;", "positive_passages": [{"docid": "doc-en-react-473a4b58713ca7c8d0e8060a45651ad2625b8e108683a3fbb58f5695d87bc14b", "text": "Do you want to request a feature or report a bug? Report a bug What is the current behavior? The hook's value is shown as in React DevTools if the value is a string or a number. Clicking on the bug icon prints the correct values to console. ! If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. CodeSandbox: Direct link to page so you can see the DevTools: What is the expected behavior? The DevTools should show the correct value of the hook. Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React? React 16.9.0. Google Chrome [Version 77.0.3865.90 (Official Build) (64-bit)] running on Linux x64. This issue appeared after version 4.1.0 (9/19/2019) of the DevTools Chrome extension. Might be same bug as but this one appears without any complicated reproduction steps.\nLooks like the issue also appears with boolean values.\nHaving the same problem. The extension worked fine after I downgraded React to version 16.8.6\nI think the only significant difference between React v16.8 and v16.9 is that v16.9 injects the function DevTools uses to support editable hooks (in other words, DevTools is using a different code path when you run v16.8 vs v16.9). I think that means this bug is probably related to somehow. Will dig in more.\nShould be fixed by\nThis fix will be released with 4.1.1 (sometime soon)\nThis fix has just been published to NPM and posted to Chrome/Firefox as v4.1.1", "commid": "react_issue_16859", "tokennum": 400}], "negative_passages": []}
{"query_id": "q-en-react-9888ae1c7238e1270c14b9088923185b7af115382f48ae3c3e0a5b9f8dbc74c7", "query": "disableInputAttributeSyncing, enableTrustedTypesIntegration, deferPassiveEffectCleanupDuringUnmount, <ins> warnAboutShorthandPropertyCollision, </ins> } = require('ReactFeatureFlags'); // In www, we have experimental support for gathering data", "positive_passages": [{"docid": "doc-en-react-dc8da7a6c3fb2961be71e65b461606628545463378521ea8f9e19712a73591ca", "text": "I a \"bug\" today that made me spent 1h figuring out what was going on: I'm using an external component that accepts a prop in order to set the of the root element, but this same component also accepts a prop which I wasn't passing, and by default, it was set to . The result: React didn't throw an error nor a warning, however, the resulting element in the DOM didn't contain either or , and since the element had a default coming from a CSS class, it took me a while to figure out why the color that I was passing wasn't being applied, and instead it was using the one from the CSS class. See: What I reported above was the case. I other cases as a bonus, as when I was playing with this they also seemed weird to me. On I define the same properties, but because I change the order, it works. On the toggleable ones, initially I can see the background, but after changing it never appears anymore. I'm not sure if I created those extra \"test cases\" correctly. My main concern is really around static1 not outputting anything on the console as a warning. Related issues: I wonder if ( should have covered this?\nThis issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution.\nClosing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information. Thank you!\nit seems that the bot automatically closed the issue, but this still needs action. I took a time to investigate it, and I realized that the work Sophie has done covers this case, but there's just one problem: it's disabled under a . I built it locally and flipped the flag, and it works: I can see the helpful warning. It was flagged in , and as per the PR, the original intention was to unflag it on the next minor. Since then we had at least 4 new minor versions, but it is still flagged. Is there a special reason for that or was it just forgotten? tagging you since you this flag, so I'm hoping you can give context here.\nCan we unflag this?\nThis was released.", "commid": "react_issue_16393", "tokennum": 488}], "negative_passages": []}
{"query_id": "q-en-react-9ba6921f4a8333ed819930489bb5d73b9a552824aaa3b08f3b4403f55db3f94e", "query": "// TODO: we should warn here. }); }); <ins> describe('checked inputs without a value property', function() { // In absence of a value, radio and checkboxes report a value of \"on\". // Between 16 and 16.2, we assigned a node's value to it's current // value in order to \"dettach\" it from defaultValue. This had the unfortunate // side-effect of assigning value=\"on\" to radio and checkboxes it('does not add \"on\" in absence of value on a checkbox', function() { const container = document.createElement('div'); ReactDOM.render( <input type=\"checkbox\" defaultChecked={true} />, container, ); const node = container.firstChild; expect(node.value).toBe('on'); expect(node.hasAttribute('value')).toBe(false); }); it('does not add \"on\" in absence of value on a radio', function() { const container = document.createElement('div'); ReactDOM.render(<input type=\"radio\" defaultChecked={true} />, container); const node = container.firstChild; expect(node.value).toBe('on'); expect(node.hasAttribute('value')).toBe(false); }); }); </ins> });", "positive_passages": [{"docid": "doc-en-react-1cb90c7aac9a7cfe40becf0eca154c58c77a676f1f4e00a566e75f770585c004", "text": "Do you want to request a feature or report a bug? Report a bug What is the current behavior? React sets (via attributes / defaultValue) on all inputs with and no value. If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to your JSFiddle () or CodeSandbox () example below: (actual, React) (expected, vanilla DOM) What is the expected behavior? value attribute should be empty unless passed via props. Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React? React 15+, any browser.\ncc\nI think this happens because the default value reported by checkboxes and radios is \"on\", in absence of a value property/attribute. Unfortunately, for ~16 our controlled text input code \"detatches\" value by assigning it over: We have some updates on master that prevent this, but I'll prep a test case for it and send it out. I'm also working on a PR that isolates the controlled checked and controlled value code to help prevent accidents like this in the future.\nSent with Lucky number .\nWe now have a test to confirm that this works as intended on master. This should land in the next release of React.", "commid": "react_issue_11998", "tokennum": 302}], "negative_passages": []}
{"query_id": "q-en-react-9bab5275716e0c80daba4826734d2ffe2700ac602b62960aaae5e4295f7e593c", "query": "\"benchmark\": \"~1.0.0\", \"browserify\": \"~3.20.0\", \"coverify\": \"~1.0.4\", <del> \"envify\": \"~1.0.1\", </del> <ins> \"envify\": \"~1.2.0\", </ins> \"es3ify\": \"~0.1.2\", \"es5-shim\": \"~2.3.0\", \"grunt\": \"~0.4.2\",", "positive_passages": [{"docid": "doc-en-react-832461d1f72ff21d99d4083f935ce25899a30aae17475b0c8a67c7f1b0380ed5", "text": "React 0.8 React 0.9 I think this is because of switched to in 1.0.0. I submitted a to envify which uses instead of recast. This brings us back to 1.5s and delivers the same advantages as recast version (preserves code formatting): I think this is blocker for 0.9.0.\nWhat command are you running, and in what directory? I'm having trouble reproducing the slow-down with just .", "commid": "react_issue_1108", "tokennum": 102}], "negative_passages": []}
{"query_id": "q-en-react-9d45934101cb246de773a499821a35ddd7d6a1ada72305a31979c7b3af0a7650", "query": "charSet: null, challenge: null, checked: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE, <ins> cite: null, </ins> classID: null, className: null, cols: HAS_POSITIVE_NUMERIC_VALUE,", "positive_passages": [{"docid": "doc-en-react-d767012c53578a4252ea756ea2bec051c5c85387c9196208e45642bc9e10703d", "text": "is currently only supported as element, not as attribute in . Since it is unknown to react it's thrown away on render.\nI'd like to take this!\nIt's yours Let me know if you have any questions.\nCool! :+1:\nCan we get this into a PR pretty please? :o)\nUmm this was merged 3 years ago already...\nmy apologies. I came across this from a Google search after using cite in blockquote in React 16.8.6 was throwing an error for me at build time. I'll have to dig deeper into the cause.", "commid": "react_issue_6084", "tokennum": 123}], "negative_passages": []}
{"query_id": "q-en-react-9df92b0e5d61e86c236bdc38559c41b06e0c72a3c7e46abcf312215f2ca96a57", "query": "<h3>A Component Using External Plugins</h3> <p> React is flexible and provides hooks that allow you to interface with <del> other libraries and frameworks. This example uses Showdown, an external </del> <ins> other libraries and frameworks. This example uses **marked**, an external </ins> Markdown library, to convert the textarea's value in real-time. </p> <div id=\"markdownExample\"></div> </div> </div> <del> <script type=\"text/javascript\" src=\"js/examples/hello.js\"></script> <script type=\"text/javascript\" src=\"js/examples/timer.js\"></script> <script type=\"text/javascript\" src=\"js/examples/todo.js\"></script> <script type=\"text/javascript\" src=\"js/examples/markdown.js\"></script> </del> <ins> <script type=\"text/javascript\" src=\"/react/js/marked.min.js\"></script> <script type=\"text/javascript\" src=\"/react/js/examples/hello.js\"></script> <script type=\"text/javascript\" src=\"/react/js/examples/timer.js\"></script> <script type=\"text/javascript\" src=\"/react/js/examples/todo.js\"></script> <script type=\"text/javascript\" src=\"/react/js/examples/markdown.js\"></script> </ins> </section> <hr class=\"home-divider\" /> <section class=\"home-bottom-section\">", "positive_passages": [{"docid": "doc-en-react-bda68aba5b773f0e231d8ae9f598c5dea11ff75961a86d42353566558f7ff8f7", "text": "Since copy+pasting our code makes it too easy for people to XSS themselves, lets just add a comment in there about it.\nPR at - let me know if that's what you had in mind!\nMy intuition is that it makes more sense to fix the example (call a sanitization library) or to change the example completely (demonstrate something else that is safer). It looks really bad to have a security warning on the homepage of the react site. Makes it seem like our framework encourages unsafe operations, rather than a safe-by-default way of doing things.\nShould switch the demo to use a different library like markdown-js that escapes everything and doesn't support HTML:\nmarkdown-js looks good. First attempt: ,output Code licensed if someone wants to turn this into a coherent example; I've signed the CLA.\nThat's a good suggestion too :) - what are your thoughts? I'm happy to change the example to use like people have suggested above. nice usage example :+1:\nUh yea, that sounds fine to me. This behavior is definitely non-standard markdown but it's an example so not a big deal. We should probably do the same for the tutorial while we're here. And it's on cdnjs so that's all pretty easy:\nJust going to use marked instead, which I'm already familiar with and has an option to sanitize input.", "commid": "react_issue_3501", "tokennum": 304}], "negative_passages": []}
{"query_id": "q-en-react-a13c5626a6a09da83ac4356b8f1bbf8d53ddca0a5ea240306c3b288a58fd84c5", "query": "export const disableJavaScriptURLs = false; export const disableInputAttributeSyncing = false; export const exposeConcurrentModeAPIs = __EXPERIMENTAL__; <del> export const warnAboutShorthandPropertyCollision = false; </del> <ins> export const warnAboutShorthandPropertyCollision = true; </ins> export const enableSchedulerDebugging = false; export const enableDeprecatedFlareAPI = false; export const enableFundamentalAPI = false;", "positive_passages": [{"docid": "doc-en-react-dc8da7a6c3fb2961be71e65b461606628545463378521ea8f9e19712a73591ca", "text": "I a \"bug\" today that made me spent 1h figuring out what was going on: I'm using an external component that accepts a prop in order to set the of the root element, but this same component also accepts a prop which I wasn't passing, and by default, it was set to . The result: React didn't throw an error nor a warning, however, the resulting element in the DOM didn't contain either or , and since the element had a default coming from a CSS class, it took me a while to figure out why the color that I was passing wasn't being applied, and instead it was using the one from the CSS class. See: What I reported above was the case. I other cases as a bonus, as when I was playing with this they also seemed weird to me. On I define the same properties, but because I change the order, it works. On the toggleable ones, initially I can see the background, but after changing it never appears anymore. I'm not sure if I created those extra \"test cases\" correctly. My main concern is really around static1 not outputting anything on the console as a warning. Related issues: I wonder if ( should have covered this?\nThis issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution.\nClosing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information. Thank you!\nit seems that the bot automatically closed the issue, but this still needs action. I took a time to investigate it, and I realized that the work Sophie has done covers this case, but there's just one problem: it's disabled under a . I built it locally and flipped the flag, and it works: I can see the helpful warning. It was flagged in , and as per the PR, the original intention was to unflag it on the next minor. Since then we had at least 4 new minor versions, but it is still flagged. Is there a special reason for that or was it just forgotten? tagging you since you this flag, so I'm hoping you can give context here.\nCan we unflag this?\nThis was released.", "commid": "react_issue_16393", "tokennum": 488}], "negative_passages": []}
{"query_id": "q-en-react-a16d084bfe68f2f91f3fb88388c4a1abb2300f395e049656f487a78845a3a100", "query": "expect(console.error.argsForCall.length).toBe(0); }); <ins> it('should not enumerate enumerable numbers (#4776)', function() { /*eslint-disable no-extend-native */ Number.prototype['@@iterator'] = function() { throw new Error('number iterator called'); }; /*eslint-enable no-extend-native */ try { void ( <div> {5} {12} {13} </div> ); } finally { delete Number.prototype['@@iterator']; } }); </ins> });", "positive_passages": [{"docid": "doc-en-react-e67de791693db938af10b78c2ee6743684ef35b812d1374870cdb39182ae80b2", "text": "Issue with the reproducible example . Full build contains non-standard iterator. Theoretical, it can be to ES in the future, it can be (or already ) to another libraries. should take into account possibility iterable numbers.\nWell, the good news is that if this is already on enough pages, then introducing iterable numbers may not be web compatible anyway. I think that this is only in DEV only code. Unfortunately a lot of pages incorrectly uses the DEV build of React.\n\"good news\"", "commid": "react_issue_4776", "tokennum": 106}], "negative_passages": []}
{"query_id": "q-en-react-a2fc3bc3907ab56ec8f7ace19e9f7f30d27881628ed908f1ffc0fab543d229ae", "query": "]); }); <ins> it('warns for bad useImperativeHandle first arg', () => { const {useImperativeHandle} = React; function App() { useImperativeHandle({ focus() {}, }); return null; } expect(() => { expect(() => { ReactTestRenderer.create(<App />); }).toThrow('create is not a function'); }).toWarnDev([ 'Expected useImperativeHandle() first argument to either be a ' + 'ref callback or React.createRef() object. ' + 'Instead received: an object with keys {focus}.', 'Expected useImperativeHandle() second argument to be a function ' + 'that creates a handle. Instead received: undefined.', ]); }); it('warns for bad useImperativeHandle second arg', () => { const {useImperativeHandle} = React; const App = React.forwardRef((props, ref) => { useImperativeHandle(ref, { focus() {}, }); return null; }); expect(() => { ReactTestRenderer.create(<App />); }).toWarnDev([ 'Expected useImperativeHandle() second argument to be a function ' + 'that creates a handle. Instead received: object.', ]); }); </ins> // https://github.com/facebook/react/issues/14022 it('works with ReactDOMServer calls inside a component', () => { const {useState} = React;", "positive_passages": [{"docid": "doc-en-react-32fed7447c33e1c49292377f28ba22b1f003566fcb0c01f418bb8b8e131f1319", "text": "I've noticed a strange bug with the react redux opt-in. If i use it with a connected class component, everything is ok: If i use it with a connected functional component that use with , i obtain a strange error: in method. I create a codepen to reproduce the issue: PS: Sorry for the cors error, but i don't find the way to add as cdn\nI believe the issue here is that expects the second argument to be a function that returns the reference: See: for more information about the API of the hook. Maybe the error thrown could be more clear?\nYou're right, accept a function as second argument. A warning on wrong argument type could be a good idea.\nIll take this issue on\nSure\ni get TypeError: React.useImperativeMethods is not a function in 16.8.0-alpha.1 but when back to 16.7.0-alpha.2 not get this error\nThe hook was renamed in this PR: Most likely between the 16.7 alpha and 16.8 alpha\nYeah, it was renamed.\nyes it work good after rename it where i can get changes between alpha version ?\nCommit log. We don't write changelogs for alphas.\nI'm taking this in since we want to get Hooks out sooner.\nalright np", "commid": "react_issue_14629", "tokennum": 277}], "negative_passages": []}
{"query_id": "q-en-react-a5393811d28ac96fe3b6ed5863705d78a713b336601971def322c7a1ebba147a", "query": "<meta property=\"og:description\" content=\"A JavaScript library for building user interfaces\" /> <link rel=\"shortcut icon\" href=\"/react/favicon.ico\"> <ins> <link rel=\"alternate\" type=\"application/rss+xml\" title=\"{{ site.name }}\" href=\"{{ site.url }}{{ site.baseurl }}/feed.xml\"> </ins> <link rel=\"stylesheet\" href=\"/react/css/react.css\"> <link rel=\"stylesheet\" href=\"/react/css/syntax.css\">", "positive_passages": [{"docid": "doc-en-react-0096013fb4cf0b8fdc3e43b92829e482b2e25e28b443871d5fa8617b278878ee", "text": "As it is known (but ), React's SyntheticEvent is pooled. This is confusing for many users as they don't understand why the event starts to behave strangely when used in an async callback, like inside a , a or a callback. There has already been an attempt to solve this problem here: The code of SyntheticEvent's default methods is: It may make sense to be more defensive because calling on a pooled event will raise . It would be more useful to add a check like:\nTo illustrate the problem in not being defensive, I would give you this commit that has made it into production as a workaround in React-tappable: Basically the user is trying to assign an empty function to a SyntheticEvent that as been put back in the pool (the call to persist was from another PR at the same time). And we were basically 3 concurrent PR to try different solutions to the exact same problem.\nAs the person who made the PR in a panic, I did find the code that broke in react itself. the preventDefault method tries to call the method on . A simple if check for in the method, and a no-op if null would be a great fix to this problem. Similar to how setState is handled on an unmounted component.\nI think React should not swallow this error and be fail fast, because this does not make any sense to preventDefault in an async callback (because the default already has been applied), React should rather throw an error. But this is only my opinion, because the browser behavior with dom events is not fail fast and swallow that bad usage of preventDefault. I mean the browser does not throw an error when we do: It simply has no effect (like what you suggest) I don't like this and would rather change the behavior of both React and the browser, but I don't think I can do much on my own... Maybe at least React could issue a warning in DEV env?\nYeah, I think warning is appropriate here.\nA warning would be great!\nJust wonder what kind of message should be put into this warning. If event pooling is not going to be documented (will it?), it may be strange to explain the pooling system inside a warning no?\nYes, event pooling should/will be documented. Feel free to submit a PR. We should add a warning to let the user know that the event has been returned to the pool and so invoking methods on it makes no sense.", "commid": "react_issue_4514", "tokennum": 527}], "negative_passages": []}
{"query_id": "q-en-react-a5393811d28ac96fe3b6ed5863705d78a713b336601971def322c7a1ebba147a", "query": "<meta property=\"og:description\" content=\"A JavaScript library for building user interfaces\" /> <link rel=\"shortcut icon\" href=\"/react/favicon.ico\"> <ins> <link rel=\"alternate\" type=\"application/rss+xml\" title=\"{{ site.name }}\" href=\"{{ site.url }}{{ site.baseurl }}/feed.xml\"> </ins> <link rel=\"stylesheet\" href=\"/react/css/react.css\"> <link rel=\"stylesheet\" href=\"/react/css/syntax.css\">", "positive_passages": [{"docid": "doc-en-react-a921f1409d3df9aa98ff285bf83b4494772cc9ad53fb31860c5c3a2f4b8d23cf", "text": "Once the docs are written, we can add a link to the end of the warning.\nGot a PR for this! Would really appreciate some feedback.", "commid": "react_issue_4514", "tokennum": 31}], "negative_passages": []}
{"query_id": "q-en-react-ad7d3d246a9829d2994dd8fea4e6b62a9c0b15d2f6d4546f09c02ad0a9242ced", "query": "inst._wrapperState = {selected: selected}; }, <ins> postMountWrapper: function(inst) { // value=\"\" should make a value attribute (#6219) var props = inst._currentElement.props; if (props.value != null) { var node = ReactDOMComponentTree.getNodeFromInstance(inst); node.setAttribute('value', props.value); } }, </ins> getNativeProps: function(inst, props) { var nativeProps = Object.assign({selected: undefined, children: undefined}, props);", "positive_passages": [{"docid": "doc-en-react-02f66d4e335d6ddaefdaada0c5924337c1569646c887a9e0f46ffcf90b1e6c5d", "text": "Appears to be working in Firefox but at least Chrome & Safari are broken. Should be a really recent regression so very few possible changes to blame... Easiest repo: the todo list on our homepage.\nJust a heads up but this still seems to be an issue even on 15.4.1. I've been struggling to reproduce this because it seems to be some sort of ninja bug. Nevertheless, I was wondering if anyone is still dealing with this problem?\nI haven't seen anything.\nI'm still seeing this issue.\nPlease open a new issue with a simplified repro case if you're still seeing this!", "commid": "react_issue_6445", "tokennum": 133}], "negative_passages": []}
{"query_id": "q-en-react-ae331086cfe1a2af73bc3f843af0a01084523a7a996aabb5b518a7aac3e1d250", "query": "<ins> module Jekyll module SidebarItemFilter def sidebar_item_link(item) pageID = @context.registers[:page][\"id\"] itemID = item[\"id\"] href = item[\"href\"] || \"/react/docs/#{itemID}.html\" className = pageID == itemID ? ' class=\"active\"' : '' return \"<a href=\"#{href}\"#{className}>#{item[\"title\"]}</a>\" end end end Liquid::Template.register_filter(Jekyll::SidebarItemFilter) </ins>", "positive_passages": [{"docid": "doc-en-react-184f91d84492376e91bb3ce0eef633ad1d542d121a8387ded7325160c8768b6a", "text": "We're basically keeping 2 copies of documentation in sync and failing. We should just point at and We should maybe make the permalinks on our site redirect or just link offsite. We should also look for links in our docs pointing to those pages and update.\ncc\nalso cc\nDefinitively agreed, we should link all the traffic to the dedicated website. See the Complementary section on Flux website", "commid": "react_issue_2229", "tokennum": 83}], "negative_passages": []}
{"query_id": "q-en-react-b10e45d1acff1b55b310a3b4ef3351361d8357d3dd8a8d2e3fb1bc831406617e", "query": "miss: A => Promise<V>, missArg: A, ): void { <del> const record: Record<V> = accessRecord(resourceType, key); </del> <ins> const record: Record<K, V> = accessRecord(resourceType, key); </ins> switch (record.status) { case Empty: // Warm the cache.", "positive_passages": [{"docid": "doc-en-react-6b3c5af2ada23f47aa80eedc03ca3a83d950eba15ef87f3dd6836f67ab1f9949", "text": "In we landed a change to the Flow types in , making the types for the various types recursive with their and properties. On that PR we may have been running an older version of Flow - I'm not having luck finding the record of when Flow ran for that PR, so not sure. In any case, that PR was merged even though it had the recursive Flow type definitions, plus one or more Flow errors which were unrelated and not detected. The problem with the recursive type definitions is that recent versions of Flow will go into an infinite loop if they try to infer types which are recursive. The solution may be to add more detail to those types, but to unblock things we temporarily made them looser type definitions.", "commid": "react_issue_12941", "tokennum": 154}], "negative_passages": []}
{"query_id": "q-en-react-b14c69f347268ede884dfa0030412349be926bb0fab35b9484b9dd061e0eeebf", "query": "// Control this behavior with a flag to support 16.6 minor releases in the meanwhile. export const exposeConcurrentModeAPIs = __EXPERIMENTAL__; <del> export const warnAboutShorthandPropertyCollision = false; </del> <ins> export const warnAboutShorthandPropertyCollision = true; </ins> // Experimental React Flare event system and event components support. export const enableDeprecatedFlareAPI = false;", "positive_passages": [{"docid": "doc-en-react-dc8da7a6c3fb2961be71e65b461606628545463378521ea8f9e19712a73591ca", "text": "I a \"bug\" today that made me spent 1h figuring out what was going on: I'm using an external component that accepts a prop in order to set the of the root element, but this same component also accepts a prop which I wasn't passing, and by default, it was set to . The result: React didn't throw an error nor a warning, however, the resulting element in the DOM didn't contain either or , and since the element had a default coming from a CSS class, it took me a while to figure out why the color that I was passing wasn't being applied, and instead it was using the one from the CSS class. See: What I reported above was the case. I other cases as a bonus, as when I was playing with this they also seemed weird to me. On I define the same properties, but because I change the order, it works. On the toggleable ones, initially I can see the background, but after changing it never appears anymore. I'm not sure if I created those extra \"test cases\" correctly. My main concern is really around static1 not outputting anything on the console as a warning. Related issues: I wonder if ( should have covered this?\nThis issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution.\nClosing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information. Thank you!\nit seems that the bot automatically closed the issue, but this still needs action. I took a time to investigate it, and I realized that the work Sophie has done covers this case, but there's just one problem: it's disabled under a . I built it locally and flipped the flag, and it works: I can see the helpful warning. It was flagged in , and as per the PR, the original intention was to unflag it on the next minor. Since then we had at least 4 new minor versions, but it is still flagged. Is there a special reason for that or was it just forgotten? tagging you since you this flag, so I'm hoping you can give context here.\nCan we unflag this?\nThis was released.", "commid": "react_issue_16393", "tokennum": 488}], "negative_passages": []}
{"query_id": "q-en-react-b1519f314bfffaf415cf930144d222c8a1f05b3be25746cc6b8ac66f08522fa8", "query": "<script src=\"https://fb.me/react-{{site.react_version}}.js\"></script> <script src=\"https://fb.me/JSXTransformer-{{site.react_version}}.js\"></script> <script src=\"https://code.jquery.com/jquery-1.10.0.min.js\"></script> <del> <script src=\"https://cdnjs.cloudflare.com/ajax/libs/showdown/0.3.1/showdown.min.js\"></script> </del> <ins> <script src=\"https://cdnjs.cloudflare.com/ajax/libs/marked/0.3.2/marked.min.js\"></script> </ins> </head> ``` Next, let's convert the comment text to Markdown and output it: <del> ```javascript{2,10} </del> <ins> ```javascript{9} </ins> // tutorial6.js <del> var converter = new Showdown.converter(); </del> var Comment = React.createClass({ render: function() { return (", "positive_passages": [{"docid": "doc-en-react-bda68aba5b773f0e231d8ae9f598c5dea11ff75961a86d42353566558f7ff8f7", "text": "Since copy+pasting our code makes it too easy for people to XSS themselves, lets just add a comment in there about it.\nPR at - let me know if that's what you had in mind!\nMy intuition is that it makes more sense to fix the example (call a sanitization library) or to change the example completely (demonstrate something else that is safer). It looks really bad to have a security warning on the homepage of the react site. Makes it seem like our framework encourages unsafe operations, rather than a safe-by-default way of doing things.\nShould switch the demo to use a different library like markdown-js that escapes everything and doesn't support HTML:\nmarkdown-js looks good. First attempt: ,output Code licensed if someone wants to turn this into a coherent example; I've signed the CLA.\nThat's a good suggestion too :) - what are your thoughts? I'm happy to change the example to use like people have suggested above. nice usage example :+1:\nUh yea, that sounds fine to me. This behavior is definitely non-standard markdown but it's an example so not a big deal. We should probably do the same for the tutorial while we're here. And it's on cdnjs so that's all pretty easy:\nJust going to use marked instead, which I'm already familiar with and has an option to sanitize input.", "commid": "react_issue_3501", "tokennum": 304}], "negative_passages": []}
{"query_id": "q-en-react-b6827fc9142f3ab746d5d6546f18c03baea8ee225bdbd9deaff9a0764cc695e8", "query": "export const replayFailedUnitOfWorkWithInvokeGuardedCallback = false; export const warnAboutDeprecatedLifecycles = true; <del> export const warnAboutShorthandPropertyCollision = false; </del> export const disableLegacyContext = false; export const warnAboutStringRefs = false; export const warnAboutDefaultPropsOnFunctionComponents = false;", "positive_passages": [{"docid": "doc-en-react-dc8da7a6c3fb2961be71e65b461606628545463378521ea8f9e19712a73591ca", "text": "I a \"bug\" today that made me spent 1h figuring out what was going on: I'm using an external component that accepts a prop in order to set the of the root element, but this same component also accepts a prop which I wasn't passing, and by default, it was set to . The result: React didn't throw an error nor a warning, however, the resulting element in the DOM didn't contain either or , and since the element had a default coming from a CSS class, it took me a while to figure out why the color that I was passing wasn't being applied, and instead it was using the one from the CSS class. See: What I reported above was the case. I other cases as a bonus, as when I was playing with this they also seemed weird to me. On I define the same properties, but because I change the order, it works. On the toggleable ones, initially I can see the background, but after changing it never appears anymore. I'm not sure if I created those extra \"test cases\" correctly. My main concern is really around static1 not outputting anything on the console as a warning. Related issues: I wonder if ( should have covered this?\nThis issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution.\nClosing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information. Thank you!\nit seems that the bot automatically closed the issue, but this still needs action. I took a time to investigate it, and I realized that the work Sophie has done covers this case, but there's just one problem: it's disabled under a . I built it locally and flipped the flag, and it works: I can see the helpful warning. It was flagged in , and as per the PR, the original intention was to unflag it on the next minor. Since then we had at least 4 new minor versions, but it is still flagged. Is there a special reason for that or was it just forgotten? tagging you since you this flag, so I'm hoping you can give context here.\nCan we unflag this?\nThis was released.", "commid": "react_issue_16393", "tokennum": 488}], "negative_passages": []}
{"query_id": "q-en-react-b79fd4faf80d63764211b4876b9981357b248a77ab807f7d175019e974fdb1ab", "query": "expect(store).toMatchSnapshot('2: add host nodes'); }); <ins> // This test is not the same cause as what's reported on GitHub, // but the resulting behavior (owner mounting after descendant) is the same. // Thec ase below is admittedly contrived and relies on side effects. // I'mnot yet sure of how to reduce the GitHub reported production case to a test though. // See https://github.com/facebook/react/issues/21445 it('should handle when a component mounts before its owner', () => { const promise = new Promise(resolve => {}); let Dynamic = null; const Owner = () => { Dynamic = <Child />; throw promise; }; const Parent = () => { return Dynamic; }; const Child = () => null; const container = document.createElement('div'); act(() => ReactDOM.render( <> <React.Suspense fallback=\"Loading...\"> <Owner /> </React.Suspense> <Parent /> </>, container, ), ); expect(store).toMatchInlineSnapshot(` [root] <Suspense> \u25be <Parent> <Child> `); }); </ins> describe('collapseNodesByDefault:false', () => { beforeEach(() => { store.collapseNodesByDefault = false;", "positive_passages": [{"docid": "doc-en-react-5b14df309377a17bd5514bd579e6532180f9dee2acbfcb39a58bb5a33ba12481", "text": "<!-- Please answer both questions below before submitting this issue. --Please provide a link to the URL of the website (if it is public), a CodeSandbox () example that reproduces the bug, or a project on GitHub that we can checkout and run locally. If possible, please describe how to reproduce this bug on the website or app mentioned above: <!-- FILL THIS IN --<!-- FILL THIS IN --<!-- FILL THIS IN --<!---------------------------------------------------<!-- Please do not remove the text below this line --<!---------------------------------------------------DevTools version: 4.13.1- Call stack: at chrome- at (chrome-) at chrome- at listener (chrome-) Component stack: (none) GitHub URL search query:\nHi I'm sorry you ran into this problem Unfortunately, it doesn't look like this issue has enough info for one of us to reproduce it though. This means that it's going to be very hard for us to fix. Please help us by providing a link to a CodeSandbox (), a repository on GitHub, or a minimal code example that reproduces the problem. (Screenshots or videos can also be helpful if they help provide context on how to repro the bug.) Here are some tips for providing a minimal example:\nI am also having this bug\nSee the comment above please :) Repro is needed.\nThis happened to me, the node wasn't appearing in the Components tree and I was getting this error. The problem was that my attribute was way too long\n! suddenly having this issue right now. I thought it was because of my commits, but changing to another old branch just give the same errors. it was working just fine yesterday, don't know why. maybe due to the devtools update or something? btw I'm on react 16.8.6, react devtools 4.13.3 (5/19/2021)\nTry updating to the latest release (4.13.4) just to rule anything out. But if you're still seeing the issue, then we still need a repro case.\nat first the bug still persists. with same error log. then I retried close the devtools and opened it again (I think I actually have done this as well before) then somehow it works now. the error log still shows up but at least now all components are showing on the devtools, and that's all I need.", "commid": "react_issue_21445", "tokennum": 634}], "negative_passages": []}
{"query_id": "q-en-react-b79fd4faf80d63764211b4876b9981357b248a77ab807f7d175019e974fdb1ab", "query": "expect(store).toMatchSnapshot('2: add host nodes'); }); <ins> // This test is not the same cause as what's reported on GitHub, // but the resulting behavior (owner mounting after descendant) is the same. // Thec ase below is admittedly contrived and relies on side effects. // I'mnot yet sure of how to reduce the GitHub reported production case to a test though. // See https://github.com/facebook/react/issues/21445 it('should handle when a component mounts before its owner', () => { const promise = new Promise(resolve => {}); let Dynamic = null; const Owner = () => { Dynamic = <Child />; throw promise; }; const Parent = () => { return Dynamic; }; const Child = () => null; const container = document.createElement('div'); act(() => ReactDOM.render( <> <React.Suspense fallback=\"Loading...\"> <Owner /> </React.Suspense> <Parent /> </>, container, ), ); expect(store).toMatchInlineSnapshot(` [root] <Suspense> \u25be <Parent> <Child> `); }); </ins> describe('collapseNodesByDefault:false', () => { beforeEach(() => { store.collapseNodesByDefault = false;", "positive_passages": [{"docid": "doc-en-react-08b723364bc5c4576a513010a372c7287da5a14b18ef1da84116bda7cdd5b8b4", "text": "in addition, I found this ! and I was trying to hide that component (which has no recent changes on it) to see whether it has any impact. or any component that last showing on the devtools. but for now, that'll be all. thank you for responding\nI appreciate the extra information, but this isn't a description that I can use to reproduce (and fix) the bug. I need an actual website (or code) that I can run along with instructions (like \"do this, then this\") so I can see the bug.\nThere are some simple code could help reproduce. You could try following code sandbox link. The reproduce steps are: \"Do not\" open develop panel. to develop panel and go to react dev tab. Errors was shown. I guess it's kind of race condition. When I change the component order such as It will work perfect. Ps: brief explain what component do. The PageLoadProgressHandler will dispatch float element to PopupPool.\nExcellent! Thank you, Super interesting that this bug only occurs if you wait to open DevTools until after the page has loaded.\nI think it is because only have two components, I have two sites, one it will always happen, another will random happen. or maybe code-sandbox do some strange things.\nThis is interesting. The reason DevTools throws is that the Fiber's owner (the attribute) points to a Fiber that hasn't been mounted yet. That seems unexpected. This repro is just a wrapper around two NPM packages. Where's the source code for these packages? :D Edit I found it, although there's a lot of indirection here_. Tracing one package which imports another which imports another. Would be helpful if it were flattened but I guess I can always step through the bundled source.\nPopupPool: PageLoadProgressHandler: Good luck... XD.\nInterestingly, if I copy the , , and source files into the sandbox (and only change the import statement in ) the bug goes away. That's surprising.\nI wonder if I'm running slightly different code? The debug log shows a slightly different tree structure.", "commid": "react_issue_21445", "tokennum": 461}], "negative_passages": []}
{"query_id": "q-en-react-b79fd4faf80d63764211b4876b9981357b248a77ab807f7d175019e974fdb1ab", "query": "expect(store).toMatchSnapshot('2: add host nodes'); }); <ins> // This test is not the same cause as what's reported on GitHub, // but the resulting behavior (owner mounting after descendant) is the same. // Thec ase below is admittedly contrived and relies on side effects. // I'mnot yet sure of how to reduce the GitHub reported production case to a test though. // See https://github.com/facebook/react/issues/21445 it('should handle when a component mounts before its owner', () => { const promise = new Promise(resolve => {}); let Dynamic = null; const Owner = () => { Dynamic = <Child />; throw promise; }; const Parent = () => { return Dynamic; }; const Child = () => null; const container = document.createElement('div'); act(() => ReactDOM.render( <> <React.Suspense fallback=\"Loading...\"> <Owner /> </React.Suspense> <Parent /> </>, container, ), ); expect(store).toMatchInlineSnapshot(` [root] <Suspense> \u25be <Parent> <Child> `); }); </ins> describe('collapseNodesByDefault:false', () => { beforeEach(() => { store.collapseNodesByDefault = false;", "positive_passages": [{"docid": "doc-en-react-a2a4fb71d5d3b864e65637ebe9f2baaf476cc588c4fe7c6119965be14b4934d0", "text": "Is the version of the source you linked me to the same as the one the Sandbox points to in NPM, Edit Looks like the repro is using 0.18.8 (released a couple of months ago) but the latest NPM release is 0.11.1. That being said, it doesn't look like the files that are being imported have changed (at least not in source) so I'm still not sure what's up.\nI change two main components to hook style then get better performance, it reduce the error happen, but I still could get error. Some error is happen after component render done and open the panel same behavior with pervious. I'll log my changes in following issue ticket.\nWould be nice to get a smaller reproduction of this issue (all of the code in one project, rather than spread across many NPM packages). That's what I was trying to do with moving the source but then the bug goes away b'c the code seems to be different. I noticed one potential difference being the indirection but I'm not sure how likely that is to be related.\nLooking at the error while debugging, it looks like the , then either renders it or dispatches a popup event to show it. I'm not sure why (too sleepy to think it through maybe) but sometimes seems to be mounting before_ has, which goes against an assumption in DevTools. Will dig back in tomorrow.\nI really appreciate the repro case, but there are so many layers of indirection between the various NPM packages being used to dynamically create the components. It's difficult to trace through. I'm going to hand this issue to you and ask for a smaller repro case. (Without 10+ NPM projects that each require each other.) Is this something you can help with? Edit I fixed this () but the test case I is not great since it relies on unsupported side effects to trigger the problem case. I'd still love to get a smaller repro so I can (1) be sure I fully fixed the problem and (2) add a regression case so it doesn't get re-introduced.\nBugfix released as\nthank you fixed on version 4.13.5\nThanks your effort. Your fixed also be success from my side.", "commid": "react_issue_21445", "tokennum": 484}], "negative_passages": []}
{"query_id": "q-en-react-b8552e574aa63e00ff7351642a17caf16de211243d02c96e8eb0e205f2b901df", "query": "var MARKDOWN_COMPONENT = ` <del> var converter = new Showdown.converter(); </del> var MarkdownEditor = React.createClass({ getInitialState: function() { return {value: 'Type some *markdown* here!'};", "positive_passages": [{"docid": "doc-en-react-bda68aba5b773f0e231d8ae9f598c5dea11ff75961a86d42353566558f7ff8f7", "text": "Since copy+pasting our code makes it too easy for people to XSS themselves, lets just add a comment in there about it.\nPR at - let me know if that's what you had in mind!\nMy intuition is that it makes more sense to fix the example (call a sanitization library) or to change the example completely (demonstrate something else that is safer). It looks really bad to have a security warning on the homepage of the react site. Makes it seem like our framework encourages unsafe operations, rather than a safe-by-default way of doing things.\nShould switch the demo to use a different library like markdown-js that escapes everything and doesn't support HTML:\nmarkdown-js looks good. First attempt: ,output Code licensed if someone wants to turn this into a coherent example; I've signed the CLA.\nThat's a good suggestion too :) - what are your thoughts? I'm happy to change the example to use like people have suggested above. nice usage example :+1:\nUh yea, that sounds fine to me. This behavior is definitely non-standard markdown but it's an example so not a big deal. We should probably do the same for the tutorial while we're here. And it's on cdnjs so that's all pretty easy:\nJust going to use marked instead, which I'm already familiar with and has an option to sanitize input.", "commid": "react_issue_3501", "tokennum": 304}], "negative_passages": []}
{"query_id": "q-en-react-c180d2073c9a432e64839c80e749b4f682291c311d8dcc032fc4a5941f414aaf", "query": "--- id: flux-overview title: Flux Application Architecture <del> next: flux-todo-list.html </del> --- <del> Flux is the application architecture that Facebook uses for building client-side web applications. It complements React's composable view components by utilizing a unidirectional data flow. It's more of a pattern rather than a formal framework, and you can start using Flux immediately without a lot of new code. <figure><iframe width=\"560\" height=\"315\" src=\"//www.youtube.com/embed/nYkdrAPrdcw?list=PLb0IAmt7-GS188xDYE-u1ShQmFFGbrk0v&start=621\" frameborder=\"0\" allowfullscreen></iframe></figure> Flux applications have three major parts: the dispatcher, the stores, and the views (React components). These should not be confused with Model-View-Controller. Controllers do exist in a Flux application, but they are controller-views \u2014 views often found at the top of the hierarchy that retrieve data from the stores and pass this data down to their children. Additionally, actions \u2014 dispatcher helper methods \u2014 are often used to support a semantic dispatcher API. It can be useful to think of them as a fourth part of the Flux update cycle. Flux eschews MVC in favor of a unidirectional data flow. When a user interacts with a React view, the view propagates an action through a central dispatcher, to the various stores that hold the application's data and business logic, which updates all of the views that are affected. This works especially well with React's declarative programming style, which allows the store to send updates without specifying how to transition views between states. We originally set out to deal correctly with derived data: for example, we wanted to show an unread count for message threads while another view showed a list of threads, with the unread ones highlighted. This was difficult to handle with MVC \u2014 marking a single thread as read would update the thread model, and then also need to update the unread count model. These dependencies and cascading updates often occur in a large MVC application, leading to a tangled weave of data flow and unpredictable results. Control is inverted with stores: the stores accept updates and reconcile them as appropriate, rather than depending on something external to update its data in a consistent way. Nothing outside the store has any insight into how it manages the data for its domain, helping to keep a clear separation of concerns. This also makes stores more testable than models, especially since stores have no direct setter methods like `setAsRead()`, but instead have only an input point for the payload, which is delivered through the dispatcher and originates with actions. ## Structure and Data Flow Data in a Flux application flows in a single direction, in a cycle: <pre> Views ---> (actions) ----> Dispatcher ---> (registered callback) ---> Stores -------+ \u0245 | | V +-- (Controller-Views \"change\" event handlers) ---- (Stores emit \"change\" events) --+ </pre> A unidirectional data flow is central to the Flux pattern, and in fact Flux takes its name from the Latin word for flow. In the above diagram, the dispatcher, stores and views are independent nodes with distinct inputs and outputs. The actions are simply discrete, semantic helper functions that facilitate passing data to the dispatcher. All data flows through the dispatcher as a central hub. Actions most often originate from user interactions with the views, and are nothing more than a call into the dispatcher. The dispatcher then invokes the callbacks that the stores have registered with it, effectively dispatching the data payload contained in the actions to all stores. Within their registered callbacks, stores determine which actions they are interested in, and respond accordingly. The stores then emit a \"change\" event to alert the controller-views that a change to the data layer has occurred. Controller-views listen for these events and retrieve data from the stores in an event handler. The controller-views call their own `render()` method via `setState()` or `forceUpdate()`, updating themselves and all of their children. This structure allows us to reason easily about our application in a way that is reminiscent of functional reactive programming, or more specifically data-flow programming or flow-based programming, where data flows through the application in a single direction \u2014 there are no two-way bindings. Application state is maintained only in the stores, allowing the different parts of the application to remain highly decoupled. Where dependencies do occur between stores, they are kept in a strict hierarchy, with synchronous updates managed by the dispatcher. We found that two-way data bindings led to cascading updates, where changing one object led to another object changing, which could also trigger more updates. As applications grew, these cascading updates made it very difficult to predict what would change as the result of one user interaction. When updates can only change data within a single round, the system as a whole becomes more predictable. Let's look at the various parts of the Flux update cycle up close. A good place to start is the dispatcher. ### A Single Dispatcher The dispatcher is the central hub that manages all data flow in a Flux application. It is essentially a registry of callbacks into the stores. Each store registers itself and provides a callback. When the dispatcher responds to an action, all stores in the application are sent the data payload provided by the action via the callbacks in the registry. As an application grows, the dispatcher becomes more vital, as it can manage dependencies between stores by invoking the registered callbacks in a specific order. Stores can declaratively wait for other stores to finish updating, and then update themselves accordingly. ### Stores Stores contain the application state and logic. Their role is somewhat similar to a model in a traditional MVC, but they manage the state of many objects \u2014 they are not instances of one object. Nor are they the same as Backbone's collections. More than simply managing a collection of ORM-style objects, stores manage the application state for a particular __domain__ within the application. For example, Facebook's [Lookback Video Editor](https://facebook.com/lookback/edit) utilized a TimeStore that kept track of the playback time position and the playback state. On the other hand, the same application's ImageStore kept track of a collection of images. The TodoStore in our [TodoMVC example](https://github.com/facebook/flux/tree/master/examples/flux-todomvc) is similar in that it manages a collection of to-do items. A store exhibits characteristics of both a collection of models and a singleton model of a logical domain. As mentioned above, a store registers itself with the dispatcher and provides it with a callback. This callback receives the action's data payload as a parameter. The payload contains a type attribute, identifying the action's type. Within the store's registered callback, a switch statement based on the action's type is used to interpret the payload and to provide the proper hooks into the store's internal methods. This allows an action to result in an update to the state of the store, via the dispatcher. After the stores are updated, they broadcast an event declaring that their state has changed, so the views may query the new state and update themselves. ### Views and Controller-Views React provides the kind of composable views we need for the view layer. Close to the top of the nested view hierarchy, a special kind of view listens for events that are broadcast by the stores that it depends on. One could call this a controller-view, as it provides the glue code to get the data from the stores and to pass this data down the chain of its descendants. We might have one of these controller-views governing any significant section of the page. When it receives the event from the store, it first requests the new data it needs via the stores' public getter methods. It then calls its own `setState()` or `forceUpdate()` methods, causing its `render()` method and the `render()` method of all its descendants to run. We often pass the entire state of the store down the chain of views in a single object, allowing different descendants to use what they need. In addition to keeping the controller-like behavior at the top of the hierarchy, and thus keeping our descendant views as functionally pure as possible, passing down the entire state of the store in a single object also has the effect of reducing the number of props we need to manage. Occasionally we may need to add additional controller-views deeper in the hierarchy to keep components simple. This might help us to better encapsulate a section of the hierarchy related to a specific data domain. Be aware, however, that controller-views deeper in the hierarchy can violate the singular flow of data by introducing a new, potentially conflicting entry point for the data flow. In making the decision of whether to add a deep controller-view, balance the gain of simpler components against the complexity of multiple data updates flowing into the hierarchy at different points. These multiple data updates can lead to odd effects, with React's render method getting invoked repeatedly by updates from different controller-views, potentially increasing the difficulty of debugging. ### Actions The dispatcher exposes a method that allows a view to trigger a dispatch to the stores, and to include a payload of data, or an action. The action construction may be wrapped into a semantic helper method which sends the payload to the dispatcher. For example, we may want to change the text of a to-do item in a to-do list application. We would create an action with a function signature like `updateText(todoId, newText)` in our `TodoActions` module. This method may be invoked from within our views' event handlers, so we can call it in response to a user action. This action method also adds the action type to the payload, so that when the payload is interpreted in the store, it can respond appropriately to a payload with a particular action type. In our example, this type might be named something like `TODO_UPDATE_TEXT`. Actions may also come from other places, such as the server. This happens, for example, during data initialization. It may also happen when the server returns an error code or when the server has updates to provide to the application. We'll talk more about server actions in a future article. In this post we're only concerned with the basics of the data flow. ### What About that Dispatcher? As mentioned earlier, the dispatcher is also able to manage dependencies between stores. This functionality is available through the `waitFor()` method within the Dispatcher class. We did not need to use this method within the extremely simple [TodoMVC application](https://github.com/facebook/flux/tree/master/examples/flux-todomvc), but we have included it [in the example dispatcher](https://github.com/facebook/flux/blob/master/examples/flux-todomvc/js/dispatcher/Dispatcher.js#L110) as an example of what a dispatcher should be able to do in a larger, more complex application. Within the TodoStore's registered callback we could explicitly wait for any dependencies to first update before moving forward: ```javascript case 'TODO_CREATE': Dispatcher.waitFor([ PrependedTextStore.dispatcherIndex, YetAnotherStore.dispatcherIndex ], function() { TodoStore.create(PrependedTextStore.getText() + ' ' + action.text); TodoStore.emit('change'); }); break; ``` The arguments for `waitFor()` are an array of dispatcher registry indexes, and a final callback to invoke after the callbacks at the given indexes have completed. Thus the store that is invoking `waitFor()` can depend on the state of another store to inform how it should update its own state. A problem arises if we create circular dependencies. If Store A waits for Store B, and B waits for A, then we'll have a very bad situation on our hands. We'll need a more robust dispatcher that flags these circular dependencies with console errors, and this is not easily accomplished with promises. Unfortunately, that's a bit beyond the scope of this documentation. In the future we hope to cover how to build a more robust dispatcher and how to initialize, update, and save the state of the application with persistent data, like a web service API. </del> <ins> This page has been moved to the Flux website. [View it there](http://facebook.github.io/flux/docs/overview.html). </ins>", "positive_passages": [{"docid": "doc-en-react-184f91d84492376e91bb3ce0eef633ad1d542d121a8387ded7325160c8768b6a", "text": "We're basically keeping 2 copies of documentation in sync and failing. We should just point at and We should maybe make the permalinks on our site redirect or just link offsite. We should also look for links in our docs pointing to those pages and update.\ncc\nalso cc\nDefinitively agreed, we should link all the traffic to the dedicated website. See the Complementary section on Flux website", "commid": "react_issue_2229", "tokennum": 83}], "negative_passages": []}
{"query_id": "q-en-react-c22c464c7d55f9d798a26062cebc144f1ff8abb669d9574b95efa6dee506e9d1", "query": "}); }); <ins> it('does change the string \".98\" to \"0.98\" with no change handler', () => { class Stub extends React.Component { state = { value: '.98', }; render() { return <input type=\"number\" value={this.state.value} />; } } var stub = ReactTestUtils.renderIntoDocument(<Stub />); var node = ReactDOM.findDOMNode(stub); stub.setState({value: '0.98'}); expect(node.value).toEqual('0.98'); }); </ins> it('should display `defaultValue` of number 0', () => { var stub = <input type=\"text\" defaultValue={0} />; stub = ReactTestUtils.renderIntoDocument(stub);", "positive_passages": [{"docid": "doc-en-react-a1ec312e283159f26e0810232ac577e1b491bd7a2e41ef77639a5a1a6e69ad7f", "text": "for example, when the original value is '.98', we need format it to '0.98'. but it is not take effect\nThis is working for me -\nyour example is not same with mine. the key is .98 can't be formated to 0.98. Because as number they are equal.\nJust housekeeping. Do we close out issues before a release with the fix has shipped or wait?\ntypically I close the issue once the has been merged into master\nAwesome, thanks! This should land in the next minor release of React:", "commid": "react_issue_9712", "tokennum": 114}], "negative_passages": []}
{"query_id": "q-en-react-c4ba2890487fd458ca56ee81ab4b26349f9cfe421c3e229f3999aca23440fcd9", "query": "</span> {typeof overrideValueFn === 'function' ? ( <EditableValue <del> dataType={type} </del> <ins> initialValue={value} </ins> overrideValueFn={overrideValueFn} path={[]} <del> value={value} </del> /> ) : ( // $FlowFixMe Cannot create span element because in property children", "positive_passages": [{"docid": "doc-en-react-473a4b58713ca7c8d0e8060a45651ad2625b8e108683a3fbb58f5695d87bc14b", "text": "Do you want to request a feature or report a bug? Report a bug What is the current behavior? The hook's value is shown as in React DevTools if the value is a string or a number. Clicking on the bug icon prints the correct values to console. ! If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. CodeSandbox: Direct link to page so you can see the DevTools: What is the expected behavior? The DevTools should show the correct value of the hook. Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React? React 16.9.0. Google Chrome [Version 77.0.3865.90 (Official Build) (64-bit)] running on Linux x64. This issue appeared after version 4.1.0 (9/19/2019) of the DevTools Chrome extension. Might be same bug as but this one appears without any complicated reproduction steps.\nLooks like the issue also appears with boolean values.\nHaving the same problem. The extension worked fine after I downgraded React to version 16.8.6\nI think the only significant difference between React v16.8 and v16.9 is that v16.9 injects the function DevTools uses to support editable hooks (in other words, DevTools is using a different code path when you run v16.8 vs v16.9). I think that means this bug is probably related to somehow. Will dig in more.\nShould be fixed by\nThis fix will be released with 4.1.1 (sometime soon)\nThis fix has just been published to NPM and posted to Chrome/Firefox as v4.1.1", "commid": "react_issue_16859", "tokennum": 400}], "negative_passages": []}
{"query_id": "q-en-react-c50a9f5c129c7397dd5315fb1e3335912e6fb5d947c794b5c5be23ade37c505d", "query": "type EditableValueProps = {| className?: string, <del> dataType: string, </del> initialValue: any, overrideValueFn: OverrideValueFn, path: Array<string | number>,", "positive_passages": [{"docid": "doc-en-react-473a4b58713ca7c8d0e8060a45651ad2625b8e108683a3fbb58f5695d87bc14b", "text": "Do you want to request a feature or report a bug? Report a bug What is the current behavior? The hook's value is shown as in React DevTools if the value is a string or a number. Clicking on the bug icon prints the correct values to console. ! If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. CodeSandbox: Direct link to page so you can see the DevTools: What is the expected behavior? The DevTools should show the correct value of the hook. Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React? React 16.9.0. Google Chrome [Version 77.0.3865.90 (Official Build) (64-bit)] running on Linux x64. This issue appeared after version 4.1.0 (9/19/2019) of the DevTools Chrome extension. Might be same bug as but this one appears without any complicated reproduction steps.\nLooks like the issue also appears with boolean values.\nHaving the same problem. The extension worked fine after I downgraded React to version 16.8.6\nI think the only significant difference between React v16.8 and v16.9 is that v16.9 injects the function DevTools uses to support editable hooks (in other words, DevTools is using a different code path when you run v16.8 vs v16.9). I think that means this bug is probably related to somehow. Will dig in more.\nShould be fixed by\nThis fix will be released with 4.1.1 (sometime soon)\nThis fix has just been published to NPM and posted to Chrome/Firefox as v4.1.1", "commid": "react_issue_16859", "tokennum": 400}], "negative_passages": []}
{"query_id": "q-en-react-c780745c5b610a34072fad7ebed437954392d35a3feb6e40cc4c6ef47b0505e1", "query": "'use strict'; var ReactChildren = require('ReactChildren'); <ins> var ReactDOMComponentTree = require('ReactDOMComponentTree'); </ins> var ReactDOMSelect = require('ReactDOMSelect'); var warning = require('warning');", "positive_passages": [{"docid": "doc-en-react-02f66d4e335d6ddaefdaada0c5924337c1569646c887a9e0f46ffcf90b1e6c5d", "text": "Appears to be working in Firefox but at least Chrome & Safari are broken. Should be a really recent regression so very few possible changes to blame... Easiest repo: the todo list on our homepage.\nJust a heads up but this still seems to be an issue even on 15.4.1. I've been struggling to reproduce this because it seems to be some sort of ninja bug. Nevertheless, I was wondering if anyone is still dealing with this problem?\nI haven't seen anything.\nI'm still seeing this issue.\nPlease open a new issue with a simplified repro case if you're still seeing this!", "commid": "react_issue_6445", "tokennum": 133}], "negative_passages": []}
{"query_id": "q-en-react-ccaceaa371777e0c90616ab74b91c66666e28c431b53df8411231ddea5909a3a", "query": "utils.catchup(openingElement.range[0], state, trimLeft); <del> if (nameObject.namespace) { throw new Error( 'Namespace tags are not supported. ReactJSX is not XML.'); </del> <ins> var isFallbackTag = false; if (nameObject.type === Syntax.XJSIdentifier) { if (nameObject.namespace) { throw new Error( 'Namespace tags are not supported. ReactJSX is not XML.'); } isFallbackTag = FALLBACK_TAGS.hasOwnProperty(nameObject.name); </ins> } <del> var isFallbackTag = FALLBACK_TAGS.hasOwnProperty(nameObject.name); utils.append( (isFallbackTag ? jsxObjIdent + '.' : '') + (nameObject.name) + '(', state ); </del> <ins> utils.append(isFallbackTag ? jsxObjIdent + '.' : '', state); utils.move(nameObject.range[0], state); utils.catchup(nameObject.range[1], state); </ins> <del> utils.move(nameObject.range[1], state); </del> <ins> utils.append('(', state); </ins> var hasAttributes = attributesObject.length;", "positive_passages": [{"docid": "doc-en-react-82a6c4b7c3975db5a9af586796aad4ea566bd9286ceba387b4e0f0b18ae6a818", "text": ":+1:\n+1\n+1\nI'mma jump on the :+1: bandwagon too. Great idea.\nI don't want to keep duplicated issues opened so just to sumup: said it makes sense to implement \"namespacing\" using colons as opt-in, config-defined option, where one of the possibilities would be a member expression. I don't have enough time to implement it this way, so I closed my issue. More on why&how in jeffmo's final comment and in in general\n+1\n+1\nA non JavaScript-first implementation that wouldn't require changes to :\nPR landing for JSX member expressions , can close this.", "commid": "react_issue_74", "tokennum": 147}], "negative_passages": []}
{"query_id": "q-en-react-cdc1efbe4b0ba6d813c962d86ff94a053c144e2ed1d5c99f425f4664d2d2d276", "query": "return () => refCallback(null); } else if (ref !== null && ref !== undefined) { const refObject = ref; <ins> if (__DEV__) { warning( refObject.hasOwnProperty('current'), 'Expected useImperativeHandle() first argument to either be a ' + 'ref callback or React.createRef() object. Instead received: %s.', 'an object with keys {' + Object.keys(refObject).join(', ') + '}', ); } </ins> const inst = create(); refObject.current = inst; return () => {", "positive_passages": [{"docid": "doc-en-react-32fed7447c33e1c49292377f28ba22b1f003566fcb0c01f418bb8b8e131f1319", "text": "I've noticed a strange bug with the react redux opt-in. If i use it with a connected class component, everything is ok: If i use it with a connected functional component that use with , i obtain a strange error: in method. I create a codepen to reproduce the issue: PS: Sorry for the cors error, but i don't find the way to add as cdn\nI believe the issue here is that expects the second argument to be a function that returns the reference: See: for more information about the API of the hook. Maybe the error thrown could be more clear?\nYou're right, accept a function as second argument. A warning on wrong argument type could be a good idea.\nIll take this issue on\nSure\ni get TypeError: React.useImperativeMethods is not a function in 16.8.0-alpha.1 but when back to 16.7.0-alpha.2 not get this error\nThe hook was renamed in this PR: Most likely between the 16.7 alpha and 16.8 alpha\nYeah, it was renamed.\nyes it work good after rename it where i can get changes between alpha version ?\nCommit log. We don't write changelogs for alphas.\nI'm taking this in since we want to get Hooks out sooner.\nalright np", "commid": "react_issue_14629", "tokennum": 277}], "negative_passages": []}
{"query_id": "q-en-react-cf4a80ca6ee0af40e77b4ffb70e4bdc2add38fd88359077b4d6604ae45634db9", "query": "nextEffect = nextEffect.nextEffect; } <ins> if (__DEV__) { resetCurrentFiber(); } </ins> } function commitPassiveEffects(root: FiberRoot, firstEffect: Fiber): void {", "positive_passages": [{"docid": "doc-en-react-32fed7447c33e1c49292377f28ba22b1f003566fcb0c01f418bb8b8e131f1319", "text": "I've noticed a strange bug with the react redux opt-in. If i use it with a connected class component, everything is ok: If i use it with a connected functional component that use with , i obtain a strange error: in method. I create a codepen to reproduce the issue: PS: Sorry for the cors error, but i don't find the way to add as cdn\nI believe the issue here is that expects the second argument to be a function that returns the reference: See: for more information about the API of the hook. Maybe the error thrown could be more clear?\nYou're right, accept a function as second argument. A warning on wrong argument type could be a good idea.\nIll take this issue on\nSure\ni get TypeError: React.useImperativeMethods is not a function in 16.8.0-alpha.1 but when back to 16.7.0-alpha.2 not get this error\nThe hook was renamed in this PR: Most likely between the 16.7 alpha and 16.8 alpha\nYeah, it was renamed.\nyes it work good after rename it where i can get changes between alpha version ?\nCommit log. We don't write changelogs for alphas.\nI'm taking this in since we want to get Hooks out sooner.\nalright np", "commid": "react_issue_14629", "tokennum": 277}], "negative_passages": []}
{"query_id": "q-en-react-d3ae4a1acc61fdbcb7663668bbb60e23452eda1e31b97abf9aacc538395b6a97", "query": "<ins> /** * marked - a markdown parser * Copyright (c) 2011-2014, Christopher Jeffrey. (MIT Licensed) * https://github.com/chjj/marked */ (function(){var block={newline:/^n+/,code:/^( {4}[^n]+n*)+/,fences:noop,hr:/^( *[-*_]){3,} *(?:n+|$)/,heading:/^ *(#{1,6}) *([^n]+?) *#* *(?:n+|$)/,nptable:noop,lheading:/^([^n]+)n *(=|-){2,} *(?:n+|$)/,blockquote:/^( *>[^n]+(n(?!def)[^n]+)*n*)+/,list:/^( *)(bull) [sS]+?(?:hr|def|n{2,}(?! )(?!1bull )n*|s*$)/,html:/^ *(?:comment|closed|closing) *(?:n{2,}|s*$)/,def:/^ *[([^]]+)]: *<?([^s>]+)>?(?: +[\"(]([^n]+)[\")])? *(?:n+|$)/,table:noop,paragraph:/^((?:[^n]+n?(?!hr|heading|lheading|blockquote|tag|def))+)n*/,text:/^[^n]+/};block.bullet=/(?:[*+-]|d+.)/;block.item=/^( *)(bull) [^n]*(?:n(?!1bull )[^n]*)*/;block.item=replace(block.item,\"gm\")(/bull/g,block.bullet)();block.list=replace(block.list)(/bull/g,block.bullet)(\"hr\",\"n+(?=1?(?:[-*_] *){3,}(?:n+|$))\")(\"def\",\"n+(?=\"+block.def.source+\")\")();block.blockquote=replace(block.blockquote)(\"def\",block.def)();block._tag=\"(?!(?:\"+\"a|em|strong|small|s|cite|q|dfn|abbr|data|time|code\"+\"|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo\"+\"|span|br|wbr|ins|del|img)b)w+(?!:/|[^ws@]*@)b\";block.html=replace(block.html)(\"comment\",/<!--[sS]*?-->/)(\"closed\",/<(tag)[sS]+?</1>/)(\"closing\",/<tag(?:\"[^\"]*\"|'[^']*'|[^'\">])*?>/)(/tag/g,block._tag)();block.paragraph=replace(block.paragraph)(\"hr\",block.hr)(\"heading\",block.heading)(\"lheading\",block.lheading)(\"blockquote\",block.blockquote)(\"tag\",\"<\"+block._tag)(\"def\",block.def)();block.normal=merge({},block);block.gfm=merge({},block.normal,{fences:/^ *(`{3,}|~{3,}) *(S+)? *n([sS]+?)s*1 *(?:n+|$)/,paragraph:/^/});block.gfm.paragraph=replace(block.paragraph)(\"(?!\",\"(?!\"+block.gfm.fences.source.replace(\"1\",\"2\")+\"|\"+block.list.source.replace(\"1\",\"3\")+\"|\")();block.tables=merge({},block.gfm,{nptable:/^ *(S.*|.*)n *([-:]+ *|[-| :]*)n((?:.*|.*(?:n|$))*)n*/,table:/^ *|(.+)n *|( *[-:]+[-| :]*)n((?: *|.*(?:n|$))*)n*/});function Lexer(options){this.tokens=[];this.tokens.links={};this.options=options||marked.defaults;this.rules=block.normal;if(this.options.gfm){if(this.options.tables){this.rules=block.tables}else{this.rules=block.gfm}}}Lexer.rules=block;Lexer.lex=function(src,options){var lexer=new Lexer(options);return lexer.lex(src)};Lexer.prototype.lex=function(src){src=src.replace(/rn|r/g,\"n\").replace(/t/g,\" \").replace(/u00a0/g,\" \").replace(/u2424/g,\"n\");return this.token(src,true)};Lexer.prototype.token=function(src,top,bq){var src=src.replace(/^ +$/gm,\"\"),next,loose,cap,bull,b,item,space,i,l;while(src){if(cap=this.rules.newline.exec(src)){src=src.substring(cap[0].length);if(cap[0].length>1){this.tokens.push({type:\"space\"})}}if(cap=this.rules.code.exec(src)){src=src.substring(cap[0].length);cap=cap[0].replace(/^ {4}/gm,\"\");this.tokens.push({type:\"code\",text:!this.options.pedantic?cap.replace(/n+$/,\"\"):cap});continue}if(cap=this.rules.fences.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:\"code\",lang:cap[2],text:cap[3]});continue}if(cap=this.rules.heading.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:\"heading\",depth:cap[1].length,text:cap[2]});continue}if(top&&(cap=this.rules.nptable.exec(src))){src=src.substring(cap[0].length);item={type:\"table\",header:cap[1].replace(/^ *| *| *$/g,\"\").split(/ *| */),align:cap[2].replace(/^ *|| *$/g,\"\").split(/ *| */),cells:cap[3].replace(/n$/,\"\").split(\"n\")};for(i=0;i<item.align.length;i++){if(/^ *-+: *$/.test(item.align[i])){item.align[i]=\"right\"}else if(/^ *:-+: *$/.test(item.align[i])){item.align[i]=\"center\"}else if(/^ *:-+ *$/.test(item.align[i])){item.align[i]=\"left\"}else{item.align[i]=null}}for(i=0;i<item.cells.length;i++){item.cells[i]=item.cells[i].split(/ *| */)}this.tokens.push(item);continue}if(cap=this.rules.lheading.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:\"heading\",depth:cap[2]===\"=\"?1:2,text:cap[1]});continue}if(cap=this.rules.hr.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:\"hr\"});continue}if(cap=this.rules.blockquote.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:\"blockquote_start\"});cap=cap[0].replace(/^ *> ?/gm,\"\");this.token(cap,top,true);this.tokens.push({type:\"blockquote_end\"});continue}if(cap=this.rules.list.exec(src)){src=src.substring(cap[0].length);bull=cap[2];this.tokens.push({type:\"list_start\",ordered:bull.length>1});cap=cap[0].match(this.rules.item);next=false;l=cap.length;i=0;for(;i<l;i++){item=cap[i];space=item.length;item=item.replace(/^ *([*+-]|d+.) +/,\"\");if(~item.indexOf(\"n \")){space-=item.length;item=!this.options.pedantic?item.replace(new RegExp(\"^ {1,\"+space+\"}\",\"gm\"),\"\"):item.replace(/^ {1,4}/gm,\"\")}if(this.options.smartLists&&i!==l-1){b=block.bullet.exec(cap[i+1])[0];if(bull!==b&&!(bull.length>1&&b.length>1)){src=cap.slice(i+1).join(\"n\")+src;i=l-1}}loose=next||/nn(?!s*$)/.test(item);if(i!==l-1){next=item.charAt(item.length-1)===\"n\";if(!loose)loose=next}this.tokens.push({type:loose?\"loose_item_start\":\"list_item_start\"});this.token(item,false,bq);this.tokens.push({type:\"list_item_end\"})}this.tokens.push({type:\"list_end\"});continue}if(cap=this.rules.html.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:this.options.sanitize?\"paragraph\":\"html\",pre:cap[1]===\"pre\"||cap[1]===\"script\"||cap[1]===\"style\",text:cap[0]});continue}if(!bq&&top&&(cap=this.rules.def.exec(src))){src=src.substring(cap[0].length);this.tokens.links[cap[1].toLowerCase()]={href:cap[2],title:cap[3]};continue}if(top&&(cap=this.rules.table.exec(src))){src=src.substring(cap[0].length);item={type:\"table\",header:cap[1].replace(/^ *| *| *$/g,\"\").split(/ *| */),align:cap[2].replace(/^ *|| *$/g,\"\").split(/ *| */),cells:cap[3].replace(/(?: *| *)?n$/,\"\").split(\"n\")};for(i=0;i<item.align.length;i++){if(/^ *-+: *$/.test(item.align[i])){item.align[i]=\"right\"}else if(/^ *:-+: *$/.test(item.align[i])){item.align[i]=\"center\"}else if(/^ *:-+ *$/.test(item.align[i])){item.align[i]=\"left\"}else{item.align[i]=null}}for(i=0;i<item.cells.length;i++){item.cells[i]=item.cells[i].replace(/^ *| *| *| *$/g,\"\").split(/ *| */)}this.tokens.push(item);continue}if(top&&(cap=this.rules.paragraph.exec(src))){src=src.substring(cap[0].length);this.tokens.push({type:\"paragraph\",text:cap[1].charAt(cap[1].length-1)===\"n\"?cap[1].slice(0,-1):cap[1]});continue}if(cap=this.rules.text.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:\"text\",text:cap[0]});continue}if(src){throw new Error(\"Infinite loop on byte: \"+src.charCodeAt(0))}}return this.tokens};var inline={escape:/^([`*{}[]()#+-.!_>])/,autolink:/^<([^ >]+(@|:/)[^ >]+)>/,url:noop,tag:/^<!--[sS]*?-->|^</?w+(?:\"[^\"]*\"|'[^']*'|[^'\">])*?>/,link:/^!?[(inside)](href)/,reflink:/^!?[(inside)]s*[([^]]*)]/,nolink:/^!?[((?:[[^]]*]|[^[]])*)]/,strong:/^__([sS]+?)__(?!_)|^**([sS]+?)**(?!*)/,em:/^b_((?:__|[sS])+?)_b|^*((?:**|[sS])+?)*(?!*)/,code:/^(`+)s*([sS]*?[^`])s*1(?!`)/,br:/^ {2,}n(?!s*$)/,del:noop,text:/^[sS]+?(?=[<![_*`]| {2,}n|$)/};inline._inside=/(?:[[^]]*]|[^[]]|](?=[^[]*]))*/;inline._href=/s*<?([sS]*?)>?(?:s+['\"]([sS]*?)['\"])?s*/;inline.link=replace(inline.link)(\"inside\",inline._inside)(\"href\",inline._href)();inline.reflink=replace(inline.reflink)(\"inside\",inline._inside)();inline.normal=merge({},inline);inline.pedantic=merge({},inline.normal,{strong:/^__(?=S)([sS]*?S)__(?!_)|^**(?=S)([sS]*?S)**(?!*)/,em:/^_(?=S)([sS]*?S)_(?!_)|^*(?=S)([sS]*?S)*(?!*)/});inline.gfm=merge({},inline.normal,{escape:replace(inline.escape)(\"])\",\"~|])\")(),url:/^(https?://[^s<]+[^<.,:;\"')]s])/,del:/^~~(?=S)([sS]*?S)~~/,text:replace(inline.text)(\"]|\",\"~]|\")(\"|\",\"|https?://|\")()});inline.breaks=merge({},inline.gfm,{br:replace(inline.br)(\"{2,}\",\"*\")(),text:replace(inline.gfm.text)(\"{2,}\",\"*\")()});function InlineLexer(links,options){this.options=options||marked.defaults;this.links=links;this.rules=inline.normal;this.renderer=this.options.renderer||new Renderer;this.renderer.options=this.options;if(!this.links){throw new Error(\"Tokens array requires a `links` property.\")}if(this.options.gfm){if(this.options.breaks){this.rules=inline.breaks}else{this.rules=inline.gfm}}else if(this.options.pedantic){this.rules=inline.pedantic}}InlineLexer.rules=inline;InlineLexer.output=function(src,links,options){var inline=new InlineLexer(links,options);return inline.output(src)};InlineLexer.prototype.output=function(src){var out=\"\",link,text,href,cap;while(src){if(cap=this.rules.escape.exec(src)){src=src.substring(cap[0].length);out+=cap[1];continue}if(cap=this.rules.autolink.exec(src)){src=src.substring(cap[0].length);if(cap[2]===\"@\"){text=cap[1].charAt(6)===\":\"?this.mangle(cap[1].substring(7)):this.mangle(cap[1]);href=this.mangle(\"mailto:\")+text}else{text=escape(cap[1]);href=text}out+=this.renderer.link(href,null,text);continue}if(!this.inLink&&(cap=this.rules.url.exec(src))){src=src.substring(cap[0].length);text=escape(cap[1]);href=text;out+=this.renderer.link(href,null,text);continue}if(cap=this.rules.tag.exec(src)){if(!this.inLink&&/^<a /i.test(cap[0])){this.inLink=true}else if(this.inLink&&/^</a>/i.test(cap[0])){this.inLink=false}src=src.substring(cap[0].length);out+=this.options.sanitize?escape(cap[0]):cap[0];continue}if(cap=this.rules.link.exec(src)){src=src.substring(cap[0].length);this.inLink=true;out+=this.outputLink(cap,{href:cap[2],title:cap[3]});this.inLink=false;continue}if((cap=this.rules.reflink.exec(src))||(cap=this.rules.nolink.exec(src))){src=src.substring(cap[0].length);link=(cap[2]||cap[1]).replace(/s+/g,\" \");link=this.links[link.toLowerCase()];if(!link||!link.href){out+=cap[0].charAt(0);src=cap[0].substring(1)+src;continue}this.inLink=true;out+=this.outputLink(cap,link);this.inLink=false;continue}if(cap=this.rules.strong.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.strong(this.output(cap[2]||cap[1]));continue}if(cap=this.rules.em.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.em(this.output(cap[2]||cap[1]));continue}if(cap=this.rules.code.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.codespan(escape(cap[2],true));continue}if(cap=this.rules.br.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.br();continue}if(cap=this.rules.del.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.del(this.output(cap[1]));continue}if(cap=this.rules.text.exec(src)){src=src.substring(cap[0].length);out+=escape(this.smartypants(cap[0]));continue}if(src){throw new Error(\"Infinite loop on byte: \"+src.charCodeAt(0))}}return out};InlineLexer.prototype.outputLink=function(cap,link){var href=escape(link.href),title=link.title?escape(link.title):null;return cap[0].charAt(0)!==\"!\"?this.renderer.link(href,title,this.output(cap[1])):this.renderer.image(href,title,escape(cap[1]))};InlineLexer.prototype.smartypants=function(text){if(!this.options.smartypants)return text;return text.replace(/--/g,\"\u2014\").replace(/(^|[-u2014/([{\"s])'/g,\"$1\u2018\").replace(/'/g,\"\u2019\").replace(/(^|[-u2014/([{u2018s])\"/g,\"$1\u201c\").replace(/\"/g,\"\u201d\").replace(/.{3}/g,\"\u2026\")};InlineLexer.prototype.mangle=function(text){var out=\"\",l=text.length,i=0,ch;for(;i<l;i++){ch=text.charCodeAt(i);if(Math.random()>.5){ch=\"x\"+ch.toString(16)}out+=\"&#\"+ch+\";\"}return out};function Renderer(options){this.options=options||{}}Renderer.prototype.code=function(code,lang,escaped){if(this.options.highlight){var out=this.options.highlight(code,lang);if(out!=null&&out!==code){escaped=true;code=out}}if(!lang){return\"<pre><code>\"+(escaped?code:escape(code,true))+\"n</code></pre>\"}return'<pre><code class=\"'+this.options.langPrefix+escape(lang,true)+'\">'+(escaped?code:escape(code,true))+\"n</code></pre>n\"};Renderer.prototype.blockquote=function(quote){return\"<blockquote>n\"+quote+\"</blockquote>n\"};Renderer.prototype.html=function(html){return html};Renderer.prototype.heading=function(text,level,raw){return\"<h\"+level+' id=\"'+this.options.headerPrefix+raw.toLowerCase().replace(/[^w]+/g,\"-\")+'\">'+text+\"</h\"+level+\">n\"};Renderer.prototype.hr=function(){return this.options.xhtml?\"<hr/>n\":\"<hr>n\"};Renderer.prototype.list=function(body,ordered){var type=ordered?\"ol\":\"ul\";return\"<\"+type+\">n\"+body+\"</\"+type+\">n\"};Renderer.prototype.listitem=function(text){return\"<li>\"+text+\"</li>n\"};Renderer.prototype.paragraph=function(text){return\"<p>\"+text+\"</p>n\"};Renderer.prototype.table=function(header,body){return\"<table>n\"+\"<thead>n\"+header+\"</thead>n\"+\"<tbody>n\"+body+\"</tbody>n\"+\"</table>n\"};Renderer.prototype.tablerow=function(content){return\"<tr>n\"+content+\"</tr>n\"};Renderer.prototype.tablecell=function(content,flags){var type=flags.header?\"th\":\"td\";var tag=flags.align?\"<\"+type+' style=\"text-align:'+flags.align+'\">':\"<\"+type+\">\";return tag+content+\"</\"+type+\">n\"};Renderer.prototype.strong=function(text){return\"<strong>\"+text+\"</strong>\"};Renderer.prototype.em=function(text){return\"<em>\"+text+\"</em>\"};Renderer.prototype.codespan=function(text){return\"<code>\"+text+\"</code>\"};Renderer.prototype.br=function(){return this.options.xhtml?\"<br/>\":\"<br>\"};Renderer.prototype.del=function(text){return\"<del>\"+text+\"</del>\"};Renderer.prototype.link=function(href,title,text){if(this.options.sanitize){try{var prot=decodeURIComponent(unescape(href)).replace(/[^w:]/g,\"\").toLowerCase()}catch(e){return\"\"}if(prot.indexOf(\"javascript:\")===0){return\"\"}}var out='<a href=\"'+href+'\"';if(title){out+=' title=\"'+title+'\"'}out+=\">\"+text+\"</a>\";return out};Renderer.prototype.image=function(href,title,text){var out='<img src=\"'+href+'\" alt=\"'+text+'\"';if(title){out+=' title=\"'+title+'\"'}out+=this.options.xhtml?\"/>\":\">\";return out};function Parser(options){this.tokens=[];this.token=null;this.options=options||marked.defaults;this.options.renderer=this.options.renderer||new Renderer;this.renderer=this.options.renderer;this.renderer.options=this.options}Parser.parse=function(src,options,renderer){var parser=new Parser(options,renderer);return parser.parse(src)};Parser.prototype.parse=function(src){this.inline=new InlineLexer(src.links,this.options,this.renderer);this.tokens=src.reverse();var out=\"\";while(this.next()){out+=this.tok()}return out};Parser.prototype.next=function(){return this.token=this.tokens.pop()};Parser.prototype.peek=function(){return this.tokens[this.tokens.length-1]||0};Parser.prototype.parseText=function(){var body=this.token.text;while(this.peek().type===\"text\"){body+=\"n\"+this.next().text}return this.inline.output(body)};Parser.prototype.tok=function(){switch(this.token.type){case\"space\":{return\"\"}case\"hr\":{return this.renderer.hr()}case\"heading\":{return this.renderer.heading(this.inline.output(this.token.text),this.token.depth,this.token.text)}case\"code\":{return this.renderer.code(this.token.text,this.token.lang,this.token.escaped)}case\"table\":{var header=\"\",body=\"\",i,row,cell,flags,j;cell=\"\";for(i=0;i<this.token.header.length;i++){flags={header:true,align:this.token.align[i]};cell+=this.renderer.tablecell(this.inline.output(this.token.header[i]),{header:true,align:this.token.align[i]})}header+=this.renderer.tablerow(cell);for(i=0;i<this.token.cells.length;i++){row=this.token.cells[i];cell=\"\";for(j=0;j<row.length;j++){cell+=this.renderer.tablecell(this.inline.output(row[j]),{header:false,align:this.token.align[j]})}body+=this.renderer.tablerow(cell)}return this.renderer.table(header,body)}case\"blockquote_start\":{var body=\"\";while(this.next().type!==\"blockquote_end\"){body+=this.tok()}return this.renderer.blockquote(body)}case\"list_start\":{var body=\"\",ordered=this.token.ordered;while(this.next().type!==\"list_end\"){body+=this.tok()}return this.renderer.list(body,ordered)}case\"list_item_start\":{var body=\"\";while(this.next().type!==\"list_item_end\"){body+=this.token.type===\"text\"?this.parseText():this.tok()}return this.renderer.listitem(body)}case\"loose_item_start\":{var body=\"\";while(this.next().type!==\"list_item_end\"){body+=this.tok()}return this.renderer.listitem(body)}case\"html\":{var html=!this.token.pre&&!this.options.pedantic?this.inline.output(this.token.text):this.token.text;return this.renderer.html(html)}case\"paragraph\":{return this.renderer.paragraph(this.inline.output(this.token.text))}case\"text\":{return this.renderer.paragraph(this.parseText())}}};function escape(html,encode){return html.replace(!encode?/&(?!#?w+;)/g:/&/g,\"&amp;\").replace(/</g,\"&lt;\").replace(/>/g,\"&gt;\").replace(/\"/g,\"&quot;\").replace(/'/g,\"&#39;\")}function unescape(html){return html.replace(/&([#w]+);/g,function(_,n){n=n.toLowerCase();if(n===\"colon\")return\":\";if(n.charAt(0)===\"#\"){return n.charAt(1)===\"x\"?String.fromCharCode(parseInt(n.substring(2),16)):String.fromCharCode(+n.substring(1))}return\"\"})}function replace(regex,opt){regex=regex.source;opt=opt||\"\";return function self(name,val){if(!name)return new RegExp(regex,opt);val=val.source||val;val=val.replace(/(^|[^[])^/g,\"$1\");regex=regex.replace(name,val);return self}}function noop(){}noop.exec=noop;function merge(obj){var i=1,target,key;for(;i<arguments.length;i++){target=arguments[i];for(key in target){if(Object.prototype.hasOwnProperty.call(target,key)){obj[key]=target[key]}}}return obj}function marked(src,opt,callback){if(callback||typeof opt===\"function\"){if(!callback){callback=opt;opt=null}opt=merge({},marked.defaults,opt||{});var highlight=opt.highlight,tokens,pending,i=0;try{tokens=Lexer.lex(src,opt)}catch(e){return callback(e)}pending=tokens.length;var done=function(){var out,err;try{out=Parser.parse(tokens,opt)}catch(e){err=e}opt.highlight=highlight;return err?callback(err):callback(null,out)};if(!highlight||highlight.length<3){return done()}delete opt.highlight;if(!pending)return done();for(;i<tokens.length;i++){(function(token){if(token.type!==\"code\"){return--pending||done()}return highlight(token.text,token.lang,function(err,code){if(code==null||code===token.text){return--pending||done()}token.text=code;token.escaped=true;--pending||done()})})(tokens[i])}return}try{if(opt)opt=merge({},marked.defaults,opt);return Parser.parse(Lexer.lex(src,opt),opt)}catch(e){e.message+=\"nPlease report this to https://github.com/chjj/marked.\";if((opt||marked.defaults).silent){return\"<p>An error occured:</p><pre>\"+escape(e.message+\"\",true)+\"</pre>\"}throw e}}marked.options=marked.setOptions=function(opt){merge(marked.defaults,opt);return marked};marked.defaults={gfm:true,tables:true,breaks:false,pedantic:false,sanitize:false,smartLists:false,silent:false,highlight:null,langPrefix:\"lang-\",smartypants:false,headerPrefix:\"\",renderer:new Renderer,xhtml:false};marked.Parser=Parser;marked.parser=Parser.parse;marked.Renderer=Renderer;marked.Lexer=Lexer;marked.lexer=Lexer.lex;marked.InlineLexer=InlineLexer;marked.inlineLexer=InlineLexer.output;marked.parse=marked;if(typeof exports===\"object\"){module.exports=marked}else if(typeof define===\"function\"&&define.amd){define(function(){return marked})}else{this.marked=marked}}).call(function(){return this||(typeof window!==\"undefined\"?window:global)}()); </ins> No newline at end of file", "positive_passages": [{"docid": "doc-en-react-bda68aba5b773f0e231d8ae9f598c5dea11ff75961a86d42353566558f7ff8f7", "text": "Since copy+pasting our code makes it too easy for people to XSS themselves, lets just add a comment in there about it.\nPR at - let me know if that's what you had in mind!\nMy intuition is that it makes more sense to fix the example (call a sanitization library) or to change the example completely (demonstrate something else that is safer). It looks really bad to have a security warning on the homepage of the react site. Makes it seem like our framework encourages unsafe operations, rather than a safe-by-default way of doing things.\nShould switch the demo to use a different library like markdown-js that escapes everything and doesn't support HTML:\nmarkdown-js looks good. First attempt: ,output Code licensed if someone wants to turn this into a coherent example; I've signed the CLA.\nThat's a good suggestion too :) - what are your thoughts? I'm happy to change the example to use like people have suggested above. nice usage example :+1:\nUh yea, that sounds fine to me. This behavior is definitely non-standard markdown but it's an example so not a big deal. We should probably do the same for the tutorial while we're here. And it's on cdnjs so that's all pretty easy:\nJust going to use marked instead, which I'm already familiar with and has an option to sanitize input.", "commid": "react_issue_3501", "tokennum": 304}], "negative_passages": []}
{"query_id": "q-en-react-d44ae03d9a1057a3b1bb7b33adce8fe2b3378c3807dca377719814b7fb837774", "query": "``` To make an uncontrolled component, `defaultValue` is used instead. <ins> > Note: > > You can pass an array into the `value` attribute, allowing you to select multiple options in a `select` tag: `<select multiple={true} value={['B', 'C']}>`. </ins>", "positive_passages": [{"docid": "doc-en-react-35ffa18c5313986ba4ea1acf01c369528d227057b1903da8bd8985c29d98a2c9", "text": "From : cc\nFixed.\nReopening because new docs don't have that info, and it is confusing. We should re-add it.\nI am looking to make my first contribution and would like to fix this issue.\nI also opened a PR for this on last week, restoring the original note. I notes for discussion on a more thorough example on the PR, like the current example has, but have not done much beyond that. Do we think that such an example would be beneficial? I almost think not, since the difference is just treating as an array with , but I'm curious to hear everyone else's thoughts on that.\nThere hasn't been any further discussion in PR or on this issue in the last two months, so is that PR all we need to do for this? cc\nSorry. We\u2019ve been busy with a rewrite for React 16, and haven\u2019t been actively reviewing the PRs.\nFixed in\nNo sweat, I figured as much. React 16 was absolutely worth it, great work!", "commid": "react_issue_1700", "tokennum": 211}], "negative_passages": []}
{"query_id": "q-en-react-d454455b62dd2f913223945713df94806cc0d6c892811ed1915445482af293ac", "query": "<ins> /** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @emails react-core */ 'use strict'; describe('ReactDOMShorthandCSSPropertyCollision', () => { let React; let ReactDOM; beforeEach(() => { jest.resetModules(); React = require('react'); ReactDOM = require('react-dom'); }); it('should warn for conflicting CSS shorthand updates', () => { const container = document.createElement('div'); ReactDOM.render(<div style={{font: 'foo', fontStyle: 'bar'}} />, container); expect(() => ReactDOM.render(<div style={{font: 'foo'}} />, container), ).toErrorDev( 'Warning: Removing a style property during rerender (fontStyle) ' + 'when a conflicting property is set (font) can lead to styling ' + \"bugs. To avoid this, don't mix shorthand and non-shorthand \" + 'properties for the same value; instead, replace the shorthand ' + 'with separate values.' + 'n in div (at **)', ); // These updates are OK and don't warn: ReactDOM.render(<div style={{font: 'qux', fontStyle: 'bar'}} />, container); ReactDOM.render(<div style={{font: 'foo', fontStyle: 'baz'}} />, container); expect(() => ReactDOM.render( <div style={{font: 'qux', fontStyle: 'baz'}} />, container, ), ).toErrorDev( 'Warning: Updating a style property during rerender (font) when ' + 'a conflicting property is set (fontStyle) can lead to styling ' + \"bugs. To avoid this, don't mix shorthand and non-shorthand \" + 'properties for the same value; instead, replace the shorthand ' + 'with separate values.' + 'n in div (at **)', ); expect(() => ReactDOM.render(<div style={{fontStyle: 'baz'}} />, container), ).toErrorDev( 'Warning: Removing a style property during rerender (font) when ' + 'a conflicting property is set (fontStyle) can lead to styling ' + \"bugs. To avoid this, don't mix shorthand and non-shorthand \" + 'properties for the same value; instead, replace the shorthand ' + 'with separate values.' + 'n in div (at **)', ); // A bit of a special case: backgroundPosition isn't technically longhand // (it expands to backgroundPosition{X,Y} but so does background) ReactDOM.render( <div style={{background: 'yellow', backgroundPosition: 'center'}} />, container, ); expect(() => ReactDOM.render(<div style={{background: 'yellow'}} />, container), ).toErrorDev( 'Warning: Removing a style property during rerender ' + '(backgroundPosition) when a conflicting property is set ' + \"(background) can lead to styling bugs. To avoid this, don't mix \" + 'shorthand and non-shorthand properties for the same value; ' + 'instead, replace the shorthand with separate values.' + 'n in div (at **)', ); ReactDOM.render( <div style={{background: 'yellow', backgroundPosition: 'center'}} />, container, ); // But setting them at the same time is OK: ReactDOM.render( <div style={{background: 'green', backgroundPosition: 'top'}} />, container, ); expect(() => ReactDOM.render(<div style={{backgroundPosition: 'top'}} />, container), ).toErrorDev( 'Warning: Removing a style property during rerender (background) ' + 'when a conflicting property is set (backgroundPosition) can lead ' + \"to styling bugs. To avoid this, don't mix shorthand and \" + 'non-shorthand properties for the same value; instead, replace the ' + 'shorthand with separate values.' + 'n in div (at **)', ); // A bit of an even more special case: borderLeft and borderStyle overlap. ReactDOM.render( <div style={{borderStyle: 'dotted', borderLeft: '1px solid red'}} />, container, ); expect(() => ReactDOM.render(<div style={{borderLeft: '1px solid red'}} />, container), ).toErrorDev( 'Warning: Removing a style property during rerender (borderStyle) ' + 'when a conflicting property is set (borderLeft) can lead to ' + \"styling bugs. To avoid this, don't mix shorthand and \" + 'non-shorthand properties for the same value; instead, replace the ' + 'shorthand with separate values.' + 'n in div (at **)', ); expect(() => ReactDOM.render( <div style={{borderStyle: 'dashed', borderLeft: '1px solid red'}} />, container, ), ).toErrorDev( 'Warning: Updating a style property during rerender (borderStyle) ' + 'when a conflicting property is set (borderLeft) can lead to ' + \"styling bugs. To avoid this, don't mix shorthand and \" + 'non-shorthand properties for the same value; instead, replace the ' + 'shorthand with separate values.' + 'n in div (at **)', ); // But setting them at the same time is OK: ReactDOM.render( <div style={{borderStyle: 'dotted', borderLeft: '2px solid red'}} />, container, ); expect(() => ReactDOM.render(<div style={{borderStyle: 'dotted'}} />, container), ).toErrorDev( 'Warning: Removing a style property during rerender (borderLeft) ' + 'when a conflicting property is set (borderStyle) can lead to ' + \"styling bugs. To avoid this, don't mix shorthand and \" + 'non-shorthand properties for the same value; instead, replace the ' + 'shorthand with separate values.' + 'n in div (at **)', ); }); }); </ins>", "positive_passages": [{"docid": "doc-en-react-dc8da7a6c3fb2961be71e65b461606628545463378521ea8f9e19712a73591ca", "text": "I a \"bug\" today that made me spent 1h figuring out what was going on: I'm using an external component that accepts a prop in order to set the of the root element, but this same component also accepts a prop which I wasn't passing, and by default, it was set to . The result: React didn't throw an error nor a warning, however, the resulting element in the DOM didn't contain either or , and since the element had a default coming from a CSS class, it took me a while to figure out why the color that I was passing wasn't being applied, and instead it was using the one from the CSS class. See: What I reported above was the case. I other cases as a bonus, as when I was playing with this they also seemed weird to me. On I define the same properties, but because I change the order, it works. On the toggleable ones, initially I can see the background, but after changing it never appears anymore. I'm not sure if I created those extra \"test cases\" correctly. My main concern is really around static1 not outputting anything on the console as a warning. Related issues: I wonder if ( should have covered this?\nThis issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution.\nClosing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information. Thank you!\nit seems that the bot automatically closed the issue, but this still needs action. I took a time to investigate it, and I realized that the work Sophie has done covers this case, but there's just one problem: it's disabled under a . I built it locally and flipped the flag, and it works: I can see the helpful warning. It was flagged in , and as per the PR, the original intention was to unflag it on the next minor. Since then we had at least 4 new minor versions, but it is still flagged. Is there a special reason for that or was it just forgotten? tagging you since you this flag, so I'm hoping you can give context here.\nCan we unflag this?\nThis was released.", "commid": "react_issue_16393", "tokennum": 488}], "negative_passages": []}
{"query_id": "q-en-react-d733bb779aa486f11eda5b2d0d3338f9da1f9f4153c09c955da8420f130a7ef6", "query": "// Simulate `input.valueAsNumber`. IE9 does not support it var valueAsNumber = parseFloat(node.value, 10) || 0; <del> // eslint-disable-next-line if (value != valueAsNumber) { </del> <ins> if ( // eslint-disable-next-line value != valueAsNumber || // eslint-disable-next-line (value == valueAsNumber && node.value != value) ) { </ins> // Cast `value` to a string to ensure the value is set correctly. While // browsers typically do this as necessary, jsdom doesn't. node.value = '' + value;", "positive_passages": [{"docid": "doc-en-react-a1ec312e283159f26e0810232ac577e1b491bd7a2e41ef77639a5a1a6e69ad7f", "text": "for example, when the original value is '.98', we need format it to '0.98'. but it is not take effect\nThis is working for me -\nyour example is not same with mine. the key is .98 can't be formated to 0.98. Because as number they are equal.\nJust housekeeping. Do we close out issues before a release with the fix has shipped or wait?\ntypically I close the issue once the has been merged into master\nAwesome, thanks! This should land in the next minor release of React:", "commid": "react_issue_9712", "tokennum": 114}], "negative_passages": []}
{"query_id": "q-en-react-d8464612c7f7ef219a367678244400cf08c4fd4d18dc9fa1ea2bb77feea370cc", "query": "let effect = firstEffect; do { <ins> if (__DEV__) { setCurrentFiber(effect); } </ins> if (effect.effectTag & Passive) { let didError = false; let error;", "positive_passages": [{"docid": "doc-en-react-32fed7447c33e1c49292377f28ba22b1f003566fcb0c01f418bb8b8e131f1319", "text": "I've noticed a strange bug with the react redux opt-in. If i use it with a connected class component, everything is ok: If i use it with a connected functional component that use with , i obtain a strange error: in method. I create a codepen to reproduce the issue: PS: Sorry for the cors error, but i don't find the way to add as cdn\nI believe the issue here is that expects the second argument to be a function that returns the reference: See: for more information about the API of the hook. Maybe the error thrown could be more clear?\nYou're right, accept a function as second argument. A warning on wrong argument type could be a good idea.\nIll take this issue on\nSure\ni get TypeError: React.useImperativeMethods is not a function in 16.8.0-alpha.1 but when back to 16.7.0-alpha.2 not get this error\nThe hook was renamed in this PR: Most likely between the 16.7 alpha and 16.8 alpha\nYeah, it was renamed.\nyes it work good after rename it where i can get changes between alpha version ?\nCommit log. We don't write changelogs for alphas.\nI'm taking this in since we want to get Hooks out sooner.\nalright np", "commid": "react_issue_14629", "tokennum": 277}], "negative_passages": []}
{"query_id": "q-en-react-d8d5f4df2e235c47218635263ee888e150aa2d7ae320aa8d06cec6450eb40e7a", "query": "When a user interacts with a React view, the view sends an action (usually represented as a JavaScript object with some fields) through the dispatcher, which notifies the various stores that hold the application's data and business logic. When the stores change state, they notify the views that something has updated. This works especially well with React's declarative model, which allows the stores to send updates without specifying how to transition views between states. <del> Flux is more of a pattern than a formal framework, so you can start using Flux immediately without a lot of new code. An [example of this architecture](https://github.com/facebook/flux/tree/master/examples/flux-todomvc) is available, along with more [detailed documentation](http://facebook.github.io/react/docs/flux-overview.html) and a [tutorial](http://facebook.github.io/react/docs/flux-todo-list.html). Look for more examples to come in the future. </del> <ins> Flux is more of a pattern than a formal framework, so you can start using Flux immediately without a lot of new code. An [example of this architecture](https://github.com/facebook/flux/tree/master/examples/flux-todomvc) is available, along with more [detailed documentation](http://facebook.github.io/flux/docs/overview.html) and a [tutorial](http://facebook.github.io/flux/docs/todo-list.html). Look for more examples to come in the future. </ins>", "positive_passages": [{"docid": "doc-en-react-184f91d84492376e91bb3ce0eef633ad1d542d121a8387ded7325160c8768b6a", "text": "We're basically keeping 2 copies of documentation in sync and failing. We should just point at and We should maybe make the permalinks on our site redirect or just link offsite. We should also look for links in our docs pointing to those pages and update.\ncc\nalso cc\nDefinitively agreed, we should link all the traffic to the dedicated website. See the Complementary section on Flux website", "commid": "react_issue_2229", "tokennum": 83}], "negative_passages": []}
{"query_id": "q-en-react-d90a9ef08029167a8aa9e5b34cd5494717848dada189e18ef5a6dc47cdbfef3e", "query": "expect(nodeValueSetter.mock.calls.length).toBe(expected); } <del> if (ReactDOMFeatureFlags.useCreateElement) { renderWithValueAndExpect(undefined, 0); renderWithValueAndExpect('', 1); renderWithValueAndExpect('foo', 2); renderWithValueAndExpect('foo', 2); renderWithValueAndExpect(undefined, 3); renderWithValueAndExpect(null, 3); renderWithValueAndExpect('', 4); renderWithValueAndExpect(undefined, 4); } else { renderWithValueAndExpect(undefined, 0); // This differs because we will have created a node with the value // attribute set. This means it will hasAttribute, so we won't try to // set the value. renderWithValueAndExpect('', 0); renderWithValueAndExpect('foo', 1); renderWithValueAndExpect('foo', 1); renderWithValueAndExpect(undefined, 2); renderWithValueAndExpect(null, 2); // Again, much like the initial update case, we will always have the // attribute set so we won't set the value. renderWithValueAndExpect('', 2); renderWithValueAndExpect(undefined, 2); } </del> <ins> renderWithValueAndExpect(undefined, 0); renderWithValueAndExpect('', 0); renderWithValueAndExpect('foo', 1); renderWithValueAndExpect('foo', 1); renderWithValueAndExpect(undefined, 2); renderWithValueAndExpect(null, 2); renderWithValueAndExpect('', 2); renderWithValueAndExpect(undefined, 2); </ins> }); it('should not incur unnecessary DOM mutations for boolean properties', function() {", "positive_passages": [{"docid": "doc-en-react-02f66d4e335d6ddaefdaada0c5924337c1569646c887a9e0f46ffcf90b1e6c5d", "text": "Appears to be working in Firefox but at least Chrome & Safari are broken. Should be a really recent regression so very few possible changes to blame... Easiest repo: the todo list on our homepage.\nJust a heads up but this still seems to be an issue even on 15.4.1. I've been struggling to reproduce this because it seems to be some sort of ninja bug. Nevertheless, I was wondering if anyone is still dealing with this problem?\nI haven't seen anything.\nI'm still seeing this issue.\nPlease open a new issue with a simplified repro case if you're still seeing this!", "commid": "react_issue_6445", "tokennum": 133}], "negative_passages": []}
{"query_id": "q-en-react-db8b3be6eb9d42b0c36d928ac658b1a2504c5caea2a34ba612fbeb6b03a60d98", "query": "injectCode(rendererCode); } <del> // Inject a `__REACT_DEVTOOLS_GLOBAL_HOOK__` global so that React can detect that the // devtools are installed (and skip its suggestion to install the devtools). injectCode( ';(' + installHook.toString() + '(window))' + saveNativeValues + detectReact, ); </del> <ins> // Inject a __REACT_DEVTOOLS_GLOBAL_HOOK__ global for React to interact with. // Only do this for HTML documents though, to avoid e.g. breaking syntax highlighting for XML docs. if (document.contentType === 'text/html') { injectCode( ';(' + installHook.toString() + '(window))' + saveNativeValues + detectReact, ); } </ins>", "positive_passages": [{"docid": "doc-en-react-4b2794ca5e07353a08e2f0daa7c1a67cb14925f720994521e725503133721b72", "text": "Steps to reproduce: 1) Disable all add-ons in Firefox 2) Open an URL that points to a XML file 3) AS EXPECTED: A pretty-printed XML is shown 4) Enable the React DevTools Add-on 5) Open the XML file again 6) FAIL: Only the content inside the XML tags are shown Using Firefox Developer Edition 72.0b6 on macOS 10.15.2\nI am able to reproduce the behavior described using Firefox Developer Edition (72.0b1) but regular Firefox (71.0) does not exhibit the buggy behavior. I don't believe this is something that the React DevTools add-on should be able to cause, since syntax highlighting is a built-in browser feature. There is no error in the console (or the add-on if I inspect it). Just enabling the extension is enough to immediately \"break\" pretty-print for XML files, e.g. I believe that this may be a Firefox Developer Edition bug. It's probably not something that an extension should be able to cause. I'll open a bug on their end: cc\nThanks! I see the same with and the LastPass add-on\nIt's unclear what Firefox is going to do on their end about this, but it seems like we can make this better by checking in the content script if is \"text/xml\" before injecting any tags.\nThis will be fixed in the next release.\nFYI this issue should be fixed in v4.4 (released today)", "commid": "react_issue_17620", "tokennum": 331}], "negative_passages": []}
{"query_id": "q-en-react-dbd19929f33e758017c96fcd0647db2a637832924b640b1cfd30732c8d156bbe", "query": "* @param {*} parentType node's parent's type. */ function validateChildKeys(node, parentType) { <ins> if (typeof node !== 'object') { return; } </ins> if (Array.isArray(node)) { for (var i = 0; i < node.length; i++) { var child = node[i];", "positive_passages": [{"docid": "doc-en-react-e67de791693db938af10b78c2ee6743684ef35b812d1374870cdb39182ae80b2", "text": "Issue with the reproducible example . Full build contains non-standard iterator. Theoretical, it can be to ES in the future, it can be (or already ) to another libraries. should take into account possibility iterable numbers.\nWell, the good news is that if this is already on enough pages, then introducing iterable numbers may not be web compatible anyway. I think that this is only in DEV only code. Unfortunately a lot of pages incorrectly uses the DEV build of React.\n\"good news\"", "commid": "react_issue_4776", "tokennum": 106}], "negative_passages": []}
{"query_id": "q-en-react-dca7b82a034ab7ad6533f7d1f0683a100f08be28851a9b21cf620eb14e80bc5e", "query": "<ul> {% for item in section.items %} <li> <del> <a href=\"/react/docs/{{ item.id }}.html\"{% if page.id == item.id %} class=\"active\"{% endif %}> {{ item.title }} </a> </del> <ins> {{ item | sidebar_item_link}} </ins> {% if item.subitems %} <ul> {% for subitem in item.subitems %} <li> <del> <a href=\"/react/docs/{{ subitem.id }}.html\"{% if page.id == subitem.id %} class=\"active\"{% endif %}> {{ subitem.title }} </a> </del> <ins> {{ item | sidebar_item_link}} </ins> </li> {% endfor %} </ul>", "positive_passages": [{"docid": "doc-en-react-184f91d84492376e91bb3ce0eef633ad1d542d121a8387ded7325160c8768b6a", "text": "We're basically keeping 2 copies of documentation in sync and failing. We should just point at and We should maybe make the permalinks on our site redirect or just link offsite. We should also look for links in our docs pointing to those pages and update.\ncc\nalso cc\nDefinitively agreed, we should link all the traffic to the dedicated website. See the Complementary section on Flux website", "commid": "react_issue_2229", "tokennum": 83}], "negative_passages": []}
{"query_id": "q-en-react-de4b308b4ae281db52e2f302d1e864600c2f3678ce0f527b2cbc8d7dd06764aa", "query": "export default function EditableValue({ className = '', <del> dataType, </del> initialValue, overrideValueFn, path,", "positive_passages": [{"docid": "doc-en-react-473a4b58713ca7c8d0e8060a45651ad2625b8e108683a3fbb58f5695d87bc14b", "text": "Do you want to request a feature or report a bug? Report a bug What is the current behavior? The hook's value is shown as in React DevTools if the value is a string or a number. Clicking on the bug icon prints the correct values to console. ! If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. CodeSandbox: Direct link to page so you can see the DevTools: What is the expected behavior? The DevTools should show the correct value of the hook. Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React? React 16.9.0. Google Chrome [Version 77.0.3865.90 (Official Build) (64-bit)] running on Linux x64. This issue appeared after version 4.1.0 (9/19/2019) of the DevTools Chrome extension. Might be same bug as but this one appears without any complicated reproduction steps.\nLooks like the issue also appears with boolean values.\nHaving the same problem. The extension worked fine after I downgraded React to version 16.8.6\nI think the only significant difference between React v16.8 and v16.9 is that v16.9 injects the function DevTools uses to support editable hooks (in other words, DevTools is using a different code path when you run v16.8 vs v16.9). I think that means this bug is probably related to somehow. Will dig in more.\nShould be fixed by\nThis fix will be released with 4.1.1 (sometime soon)\nThis fix has just been published to NPM and posted to Chrome/Firefox as v4.1.1", "commid": "react_issue_16859", "tokennum": 400}], "negative_passages": []}
{"query_id": "q-en-react-e33fa0b87f5a1528a834beed405abb0cb058d73c109456eb3f6edf7dcaf1a588", "query": "}); }, []); <del> return useMemo( () => ({ editableValue, hasPendingChanges: smartStringify(initialValue) !== editableValue, isValid, parsedValue, reset, update, }), [editableValue, initialValue, isValid, parsedValue], ); </del> <ins> return { editableValue, hasPendingChanges: smartStringify(initialValue) !== editableValue, isValid, parsedValue, reset, update, }; </ins> } export function useIsOverflowing(", "positive_passages": [{"docid": "doc-en-react-473a4b58713ca7c8d0e8060a45651ad2625b8e108683a3fbb58f5695d87bc14b", "text": "Do you want to request a feature or report a bug? Report a bug What is the current behavior? The hook's value is shown as in React DevTools if the value is a string or a number. Clicking on the bug icon prints the correct values to console. ! If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. CodeSandbox: Direct link to page so you can see the DevTools: What is the expected behavior? The DevTools should show the correct value of the hook. Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React? React 16.9.0. Google Chrome [Version 77.0.3865.90 (Official Build) (64-bit)] running on Linux x64. This issue appeared after version 4.1.0 (9/19/2019) of the DevTools Chrome extension. Might be same bug as but this one appears without any complicated reproduction steps.\nLooks like the issue also appears with boolean values.\nHaving the same problem. The extension worked fine after I downgraded React to version 16.8.6\nI think the only significant difference between React v16.8 and v16.9 is that v16.9 injects the function DevTools uses to support editable hooks (in other words, DevTools is using a different code path when you run v16.8 vs v16.9). I think that means this bug is probably related to somehow. Will dig in more.\nShould be fixed by\nThis fix will be released with 4.1.1 (sometime soon)\nThis fix has just been published to NPM and posted to Chrome/Firefox as v4.1.1", "commid": "react_issue_16859", "tokennum": 400}], "negative_passages": []}
{"query_id": "q-en-react-e549ac2c31a4e03a17bf0fa5bc34cddc002dc6f1d01f68c07436ee5da9c473de", "query": "error => { // Resource failed to load. Stash the error for later so we can throw it // the next time it's requested. <del> const rejectedRecord: RejectedRecord = (pendingRecord: any); </del> <ins> const rejectedRecord: RejectedRecord<K> = (pendingRecord: any); </ins> rejectedRecord.status = Rejected; rejectedRecord.suspender = null; rejectedRecord.error = error;", "positive_passages": [{"docid": "doc-en-react-6b3c5af2ada23f47aa80eedc03ca3a83d950eba15ef87f3dd6836f67ab1f9949", "text": "In we landed a change to the Flow types in , making the types for the various types recursive with their and properties. On that PR we may have been running an older version of Flow - I'm not having luck finding the record of when Flow ran for that PR, so not sure. In any case, that PR was merged even though it had the recursive Flow type definitions, plus one or more Flow errors which were unrelated and not detected. The problem with the recursive type definitions is that recent versions of Flow will go into an infinite loop if they try to infer types which are recursive. The solution may be to add more detail to those types, but to unblock things we temporarily made them looser type definitions.", "commid": "react_issue_12941", "tokennum": 154}], "negative_passages": []}
{"query_id": "q-en-react-e632082957a6b061fbf0cfa3f2cea9a721045ada0afeef0becb6b0eaf58bc2ea", "query": "]); }); <ins> it('should shallow render a functional component', function() { function SomeComponent() { return ( <div> <span className=\"child1\" /> <span className=\"child2\" /> </div> ); } var shallowRenderer = ReactTestUtils.createRenderer(); var result = shallowRenderer.render(<SomeComponent />); expect(result.type).toBe('div'); expect(result.props.children).toEqual([ <span className=\"child1\" />, <span className=\"child2\" />, ]); }); </ins> it('should throw for invalid elements', function() { var SomeComponent = React.createClass({ render: function() {", "positive_passages": [{"docid": "doc-en-react-ca19df289e02684e61e07a528776d59aafa3f9ae31aa0dfa1ca6abf5d058dfe3", "text": "There appears to have been a change in how is generated between 0.13 and 0.14 which is causing a number of our shallow rendered tests to fail when upgrading because the deepEquals fails on the property. Here is a simple example component which exhibits the issue.\nI've been seeing some similar issues with shallow rendering. My current (messy - sorry!) workaround is this: Let me know if that helps! My version currently breaks some of the Jest tests, but I'm happy to work on this some more and submit a PR.\nThank you very much for this, it's been a tremendous help! While this solved the problem for my test case above it still failed on a large number of our more complex tests. I've been iterating on it and once I have all of our tests passing I'll add the updated version.\nHere is the updated workaround, it works for our 238 tests of varying complexity but I'd be interested to see if it passes all of your tests as well.\nAwesome! If you don't mind trying, what happens if you do and then use the earlier ?\nMuch cleaner thanks, I guess I was in my head too much :)\nI prefer applying a monkey patch, until we have this fixed in react by wrapping TestUtils in my own module:\nThis should be fixed by .", "commid": "react_issue_5292", "tokennum": 278}], "negative_passages": []}
{"query_id": "q-en-react-e66683ec0001c256a4800ad96eb49352b02c37a01c75a14b47fe48cf9a9150b2", "query": "<del> /** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @emails react-core */ 'use strict'; describe('ReactDOMShorthandCSSPropertyCollision', () => { let ReactFeatureFlags; let React; let ReactDOM; beforeEach(() => { jest.resetModules(); ReactFeatureFlags = require('shared/ReactFeatureFlags'); ReactFeatureFlags.warnAboutShorthandPropertyCollision = true; React = require('react'); ReactDOM = require('react-dom'); }); it('should warn for conflicting CSS shorthand updates', () => { const container = document.createElement('div'); ReactDOM.render(<div style={{font: 'foo', fontStyle: 'bar'}} />, container); expect(() => ReactDOM.render(<div style={{font: 'foo'}} />, container), ).toErrorDev( 'Warning: Removing a style property during rerender (fontStyle) ' + 'when a conflicting property is set (font) can lead to styling ' + \"bugs. To avoid this, don't mix shorthand and non-shorthand \" + 'properties for the same value; instead, replace the shorthand ' + 'with separate values.' + 'n in div (at **)', ); // These updates are OK and don't warn: ReactDOM.render(<div style={{font: 'qux', fontStyle: 'bar'}} />, container); ReactDOM.render(<div style={{font: 'foo', fontStyle: 'baz'}} />, container); expect(() => ReactDOM.render( <div style={{font: 'qux', fontStyle: 'baz'}} />, container, ), ).toErrorDev( 'Warning: Updating a style property during rerender (font) when ' + 'a conflicting property is set (fontStyle) can lead to styling ' + \"bugs. To avoid this, don't mix shorthand and non-shorthand \" + 'properties for the same value; instead, replace the shorthand ' + 'with separate values.' + 'n in div (at **)', ); expect(() => ReactDOM.render(<div style={{fontStyle: 'baz'}} />, container), ).toErrorDev( 'Warning: Removing a style property during rerender (font) when ' + 'a conflicting property is set (fontStyle) can lead to styling ' + \"bugs. To avoid this, don't mix shorthand and non-shorthand \" + 'properties for the same value; instead, replace the shorthand ' + 'with separate values.' + 'n in div (at **)', ); // A bit of a special case: backgroundPosition isn't technically longhand // (it expands to backgroundPosition{X,Y} but so does background) ReactDOM.render( <div style={{background: 'yellow', backgroundPosition: 'center'}} />, container, ); expect(() => ReactDOM.render(<div style={{background: 'yellow'}} />, container), ).toErrorDev( 'Warning: Removing a style property during rerender ' + '(backgroundPosition) when a conflicting property is set ' + \"(background) can lead to styling bugs. To avoid this, don't mix \" + 'shorthand and non-shorthand properties for the same value; ' + 'instead, replace the shorthand with separate values.' + 'n in div (at **)', ); ReactDOM.render( <div style={{background: 'yellow', backgroundPosition: 'center'}} />, container, ); // But setting them at the same time is OK: ReactDOM.render( <div style={{background: 'green', backgroundPosition: 'top'}} />, container, ); expect(() => ReactDOM.render(<div style={{backgroundPosition: 'top'}} />, container), ).toErrorDev( 'Warning: Removing a style property during rerender (background) ' + 'when a conflicting property is set (backgroundPosition) can lead ' + \"to styling bugs. To avoid this, don't mix shorthand and \" + 'non-shorthand properties for the same value; instead, replace the ' + 'shorthand with separate values.' + 'n in div (at **)', ); // A bit of an even more special case: borderLeft and borderStyle overlap. ReactDOM.render( <div style={{borderStyle: 'dotted', borderLeft: '1px solid red'}} />, container, ); expect(() => ReactDOM.render(<div style={{borderLeft: '1px solid red'}} />, container), ).toErrorDev( 'Warning: Removing a style property during rerender (borderStyle) ' + 'when a conflicting property is set (borderLeft) can lead to ' + \"styling bugs. To avoid this, don't mix shorthand and \" + 'non-shorthand properties for the same value; instead, replace the ' + 'shorthand with separate values.' + 'n in div (at **)', ); expect(() => ReactDOM.render( <div style={{borderStyle: 'dashed', borderLeft: '1px solid red'}} />, container, ), ).toErrorDev( 'Warning: Updating a style property during rerender (borderStyle) ' + 'when a conflicting property is set (borderLeft) can lead to ' + \"styling bugs. To avoid this, don't mix shorthand and \" + 'non-shorthand properties for the same value; instead, replace the ' + 'shorthand with separate values.' + 'n in div (at **)', ); // But setting them at the same time is OK: ReactDOM.render( <div style={{borderStyle: 'dotted', borderLeft: '2px solid red'}} />, container, ); expect(() => ReactDOM.render(<div style={{borderStyle: 'dotted'}} />, container), ).toErrorDev( 'Warning: Removing a style property during rerender (borderLeft) ' + 'when a conflicting property is set (borderStyle) can lead to ' + \"styling bugs. To avoid this, don't mix shorthand and \" + 'non-shorthand properties for the same value; instead, replace the ' + 'shorthand with separate values.' + 'n in div (at **)', ); }); }); </del>", "positive_passages": [{"docid": "doc-en-react-dc8da7a6c3fb2961be71e65b461606628545463378521ea8f9e19712a73591ca", "text": "I a \"bug\" today that made me spent 1h figuring out what was going on: I'm using an external component that accepts a prop in order to set the of the root element, but this same component also accepts a prop which I wasn't passing, and by default, it was set to . The result: React didn't throw an error nor a warning, however, the resulting element in the DOM didn't contain either or , and since the element had a default coming from a CSS class, it took me a while to figure out why the color that I was passing wasn't being applied, and instead it was using the one from the CSS class. See: What I reported above was the case. I other cases as a bonus, as when I was playing with this they also seemed weird to me. On I define the same properties, but because I change the order, it works. On the toggleable ones, initially I can see the background, but after changing it never appears anymore. I'm not sure if I created those extra \"test cases\" correctly. My main concern is really around static1 not outputting anything on the console as a warning. Related issues: I wonder if ( should have covered this?\nThis issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution.\nClosing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information. Thank you!\nit seems that the bot automatically closed the issue, but this still needs action. I took a time to investigate it, and I realized that the work Sophie has done covers this case, but there's just one problem: it's disabled under a . I built it locally and flipped the flag, and it works: I can see the helpful warning. It was flagged in , and as per the PR, the original intention was to unflag it on the next minor. Since then we had at least 4 new minor versions, but it is still flagged. Is there a special reason for that or was it just forgotten? tagging you since you this flag, so I'm hoping you can give context here.\nCan we unflag this?\nThis was released.", "commid": "react_issue_16393", "tokennum": 488}], "negative_passages": []}
{"query_id": "q-en-react-ea4900c762fd678c5822ae17ca93f369387d71855b6e3de7116f3d13b89859b6", "query": "var node = ReactDOM.findDOMNode(stub); expect(node.innerHTML).toBe('foobar'); }); <ins> it('should set attribute for empty value', function() { var container = document.createElement('div'); var option = ReactDOM.render(<option value=\"\" />, container); expect(option.hasAttribute('value')).toBe(true); expect(option.getAttribute('value')).toBe(''); ReactDOM.render(<option value=\"lava\" />, container); expect(option.hasAttribute('value')).toBe(true); expect(option.getAttribute('value')).toBe('lava'); }); </ins> });", "positive_passages": [{"docid": "doc-en-react-02f66d4e335d6ddaefdaada0c5924337c1569646c887a9e0f46ffcf90b1e6c5d", "text": "Appears to be working in Firefox but at least Chrome & Safari are broken. Should be a really recent regression so very few possible changes to blame... Easiest repo: the todo list on our homepage.\nJust a heads up but this still seems to be an issue even on 15.4.1. I've been struggling to reproduce this because it seems to be some sort of ninja bug. Nevertheless, I was wondering if anyone is still dealing with this problem?\nI haven't seen anything.\nI'm still seeing this issue.\nPlease open a new issue with a simplified repro case if you're still seeing this!", "commid": "react_issue_6445", "tokennum": 133}], "negative_passages": []}
{"query_id": "q-en-react-ecc6a0e8201077170b665e3625402fbf8f4ffdb3bf02f4626c95a1b02d5501db", "query": "miss: A => Promise<V>, missArg: A, ): V { <del> const record: Record<V> = accessRecord(resourceType, key); </del> <ins> const record: Record<K, V> = accessRecord(resourceType, key); </ins> switch (record.status) { case Empty: // Load the requested resource.", "positive_passages": [{"docid": "doc-en-react-6b3c5af2ada23f47aa80eedc03ca3a83d950eba15ef87f3dd6836f67ab1f9949", "text": "In we landed a change to the Flow types in , making the types for the various types recursive with their and properties. On that PR we may have been running an older version of Flow - I'm not having luck finding the record of when Flow ran for that PR, so not sure. In any case, that PR was merged even though it had the recursive Flow type definitions, plus one or more Flow errors which were unrelated and not detected. The problem with the recursive type definitions is that recent versions of Flow will go into an infinite loop if they try to infer types which are recursive. The solution may be to add more detail to those types, but to unblock things we temporarily made them looser type definitions.", "commid": "react_issue_12941", "tokennum": 154}], "negative_passages": []}
{"query_id": "q-en-react-f026858d1266d4ab91d6a5a8ac281fd61d9639248a448b1d7640961fc5943b7e", "query": "key: K, value: V, error: null, <del> next: Record<K, V> | null, previous: Record<K, V> | null, </del> <ins> next: any, // TODO: (issue #12941) previous: any, // TODO: (issue #12941) /** * Proper types would be something like this: * next: Record<K, V> | null, * previous: Record<K, V> | null, */ </ins> |}; <del> type RejectedRecord<K, V> = {| </del> <ins> type RejectedRecord<K> = {| </ins> status: 3, suspender: null, key: K, value: null, error: Error, <del> next: Record<K, V> | null, previous: Record<K, V> | null, </del> <ins> next: any, // TODO: (issue #12941) previous: any, // TODO: (issue #12941) /** * Proper types would be something like this: * next: Record<K, V> | null, * previous: Record<K, V> | null, */ </ins> |}; type Record<K, V> = <del> | EmptyRecord<K, V> </del> <ins> | EmptyRecord<K> </ins> | PendingRecord<K, V> | ResolvedRecord<K, V> <del> | RejectedRecord<K, V>; </del> <ins> | RejectedRecord<K>; </ins> type RecordCache<K, V> = {| map: Map<K, Record<K, V>>, head: Record<K, V> | null, tail: Record<K, V> | null, <ins> size: number, </ins> |}; // TODO: How do you express this type with Flow?", "positive_passages": [{"docid": "doc-en-react-6b3c5af2ada23f47aa80eedc03ca3a83d950eba15ef87f3dd6836f67ab1f9949", "text": "In we landed a change to the Flow types in , making the types for the various types recursive with their and properties. On that PR we may have been running an older version of Flow - I'm not having luck finding the record of when Flow ran for that PR, so not sure. In any case, that PR was merged even though it had the recursive Flow type definitions, plus one or more Flow errors which were unrelated and not detected. The problem with the recursive type definitions is that recent versions of Flow will go into an infinite loop if they try to infer types which are recursive. The solution may be to add more detail to those types, but to unblock things we temporarily made them looser type definitions.", "commid": "react_issue_12941", "tokennum": 154}], "negative_passages": []}
{"query_id": "q-en-react-f877b520452d96b851af3f845bd6425f3d0d405a62ed065724b86124e4200801", "query": "<h2 className=\"commentAuthor\"> {this.props.author} </h2> <del> {converter.makeHtml(this.props.children.toString())} </del> <ins> {marked(this.props.children.toString())} </ins> </div> ); } }); ``` <del> All we're doing here is calling the Showdown library. We need to convert `this.props.children` from React's wrapped text to a raw string that Showdown will understand so we explicitly call `toString()`. </del> <ins> All we're doing here is calling the marked library. We need to convert `this.props.children` from React's wrapped text to a raw string that marked will understand so we explicitly call `toString()`. </ins> But there's a problem! Our rendered comments look like this in the browser: \"`<p>`This is `<em>`another`</em>` comment`</p>`\". We want those tags to actually render as HTML. That's React protecting you from an XSS attack. There's a way to get around it but the framework warns you not to use it: <del> ```javascript{5,11} </del> <ins> ```javascript{4,10} </ins> // tutorial7.js <del> var converter = new Showdown.converter(); </del> var Comment = React.createClass({ render: function() { <del> var rawMarkup = converter.makeHtml(this.props.children.toString()); </del> <ins> var rawMarkup = marked(this.props.children.toString(), {sanitize: true}); </ins> return ( <div className=\"comment\"> <h2 className=\"commentAuthor\">", "positive_passages": [{"docid": "doc-en-react-bda68aba5b773f0e231d8ae9f598c5dea11ff75961a86d42353566558f7ff8f7", "text": "Since copy+pasting our code makes it too easy for people to XSS themselves, lets just add a comment in there about it.\nPR at - let me know if that's what you had in mind!\nMy intuition is that it makes more sense to fix the example (call a sanitization library) or to change the example completely (demonstrate something else that is safer). It looks really bad to have a security warning on the homepage of the react site. Makes it seem like our framework encourages unsafe operations, rather than a safe-by-default way of doing things.\nShould switch the demo to use a different library like markdown-js that escapes everything and doesn't support HTML:\nmarkdown-js looks good. First attempt: ,output Code licensed if someone wants to turn this into a coherent example; I've signed the CLA.\nThat's a good suggestion too :) - what are your thoughts? I'm happy to change the example to use like people have suggested above. nice usage example :+1:\nUh yea, that sounds fine to me. This behavior is definitely non-standard markdown but it's an example so not a big deal. We should probably do the same for the tutorial while we're here. And it's on cdnjs so that's all pretty easy:\nJust going to use marked instead, which I'm already familiar with and has an option to sanitize input.", "commid": "react_issue_3501", "tokennum": 304}], "negative_passages": []}
{"query_id": "q-en-react-fb092a80ba176f85094c5c7560613d71a823d8943664b2f3358e78c531b252c3", "query": "--- markdown: redcarpet name: React <ins> description: A JavaScript library for building user interfaces </ins> redcarpet: extensions: - fenced_code_blocks", "positive_passages": [{"docid": "doc-en-react-0096013fb4cf0b8fdc3e43b92829e482b2e25e28b443871d5fa8617b278878ee", "text": "As it is known (but ), React's SyntheticEvent is pooled. This is confusing for many users as they don't understand why the event starts to behave strangely when used in an async callback, like inside a , a or a callback. There has already been an attempt to solve this problem here: The code of SyntheticEvent's default methods is: It may make sense to be more defensive because calling on a pooled event will raise . It would be more useful to add a check like:\nTo illustrate the problem in not being defensive, I would give you this commit that has made it into production as a workaround in React-tappable: Basically the user is trying to assign an empty function to a SyntheticEvent that as been put back in the pool (the call to persist was from another PR at the same time). And we were basically 3 concurrent PR to try different solutions to the exact same problem.\nAs the person who made the PR in a panic, I did find the code that broke in react itself. the preventDefault method tries to call the method on . A simple if check for in the method, and a no-op if null would be a great fix to this problem. Similar to how setState is handled on an unmounted component.\nI think React should not swallow this error and be fail fast, because this does not make any sense to preventDefault in an async callback (because the default already has been applied), React should rather throw an error. But this is only my opinion, because the browser behavior with dom events is not fail fast and swallow that bad usage of preventDefault. I mean the browser does not throw an error when we do: It simply has no effect (like what you suggest) I don't like this and would rather change the behavior of both React and the browser, but I don't think I can do much on my own... Maybe at least React could issue a warning in DEV env?\nYeah, I think warning is appropriate here.\nA warning would be great!\nJust wonder what kind of message should be put into this warning. If event pooling is not going to be documented (will it?), it may be strange to explain the pooling system inside a warning no?\nYes, event pooling should/will be documented. Feel free to submit a PR. We should add a warning to let the user know that the event has been returned to the pool and so invoking methods on it makes no sense.", "commid": "react_issue_4514", "tokennum": 527}], "negative_passages": []}
{"query_id": "q-en-react-fb092a80ba176f85094c5c7560613d71a823d8943664b2f3358e78c531b252c3", "query": "--- markdown: redcarpet name: React <ins> description: A JavaScript library for building user interfaces </ins> redcarpet: extensions: - fenced_code_blocks", "positive_passages": [{"docid": "doc-en-react-a921f1409d3df9aa98ff285bf83b4494772cc9ad53fb31860c5c3a2f4b8d23cf", "text": "Once the docs are written, we can add a link to the end of the warning.\nGot a PR for this! Would really appreciate some feedback.", "commid": "react_issue_4514", "tokennum": 31}], "negative_passages": []}