{"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') COMMANDS_TO_RUN+=('./scripts/circleci/upload_build.sh') 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') COMMANDS_TO_RUN+=('./scripts/circleci/upload_build.sh') 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) { if (__DEV__) { setCurrentFiber(nextEffect); } 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; function createRecord(key: K): EmptyRecord { function createRecord(key: K): EmptyRecord { 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; } function load(emptyRecord: EmptyRecord, suspender: Promise) { const pendingRecord: PendingRecord = (emptyRecord: any); function load(emptyRecord: EmptyRecord, suspender: Promise) { const pendingRecord: PendingRecord = (emptyRecord: any); pendingRecord.status = Pending; pendingRecord.suspender = suspender; suspender.then( value => { // Resource loaded successfully. const resolvedRecord: ResolvedRecord = (pendingRecord: any); const resolvedRecord: ResolvedRecord = (pendingRecord: any); 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. // Must set `value` property if it is not null and not yet set. if (!propertyInfo.hasSideEffects || ('' + node[propName]) !== ('' + value) || !node.hasAttribute(propertyInfo.attributeName)) { ('' + node[propName]) !== ('' + value)) { // 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": " {isEditable ? ( dataType={dataType} initialValue={value} overrideValueFn={((overrideValueFn: any): OverrideValueFn)} path={path} initialValue={value} /> ) : ( {displayValue}", "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; invariant( current != null, 'findFirstReactDOMImpl(...): Unexpected detached subtree found when ' + 'traversing DOM from node `%s`.', nodeID ); if (current == null) { // The passed-in node has been detached from the container it was // originally rendered into. return null; } } 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; invariant( current != null, 'findFirstReactDOMImpl(...): Unexpected detached subtree found when ' + 'traversing DOM from node `%s`.', nodeID ); if (current == null) { // The passed-in node has been detached from the container it was // originally rendered into. return null; } } 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; invariant( current != null, 'findFirstReactDOMImpl(...): Unexpected detached subtree found when ' + 'traversing DOM from node `%s`.', nodeID ); if (current == null) { // The passed-in node has been detached from the container it was // originally rendered into. return null; } } 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. 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): 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): ```html{7} ", "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; case 'option': transaction.getReactMountReady().enqueue( optionPostMount, this ); } 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\", \"build:dev\": \"cross-env NODE_ENV=development yarn run build:chrome && yarn run build:firefox && yarn run build:edge\", \"build:dev\": \"cross-env NODE_ENV=development yarn run build:chrome:dev && yarn run build:firefox:dev && yarn run build:edge:dev\", \"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": " (actions) ----> Dispatcher ---> (registered callback) ---> Stores -------+ \u0245 | | V +-- (Controller-Views \"change\" event handlers) ---- (Stores emit \"change\" events) --+ 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. This page has been moved to the Flux website. [View it there](http://facebook.github.io/flux/docs/overview.html). ", "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": "}); }); it('does change the string \".98\" to \"0.98\" with no change handler', () => { class Stub extends React.Component { state = { value: '.98', }; render() { return ; } } var stub = ReactTestUtils.renderIntoDocument(); var node = ReactDOM.findDOMNode(stub); stub.setState({value: '0.98'}); expect(node.value).toEqual('0.98'); }); it('should display `defaultValue` of number 0', () => { var stub = ; 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": " {typeof overrideValueFn === 'function' ? ( dataType={type} initialValue={value} overrideValueFn={overrideValueFn} path={[]} value={value} /> ) : ( // $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, dataType: string, initialValue: any, overrideValueFn: OverrideValueFn, path: Array,", "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'); var ReactDOMComponentTree = require('ReactDOMComponentTree'); 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); if (nameObject.namespace) { throw new Error( 'Namespace tags are not supported. ReactJSX is not XML.'); 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); } var isFallbackTag = FALLBACK_TAGS.hasOwnProperty(nameObject.name); utils.append( (isFallbackTag ? jsxObjIdent + '.' : '') + (nameObject.name) + '(', state ); utils.append(isFallbackTag ? jsxObjIdent + '.' : '', state); utils.move(nameObject.range[0], state); utils.catchup(nameObject.range[1], state); utils.move(nameObject.range[1], state); utils.append('(', state); 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; 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(', ') + '}', ); } 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; } if (__DEV__) { resetCurrentFiber(); } } 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": " /** * 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:/^ *[([^]]+)]: *]+)>?(?: +[\"(]([^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\",//)(\"closed\",/<(tag)[sS]+?/)(\"closing\",/])*?>/)(/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 ?/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(;i1&&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])/,autolink:/^<([^ >]+(@|:/)[^ >]+)>/,url:noop,tag:/^|^])*?>/,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]+?(?=[?(?: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&&/^/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.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\"
\"+(escaped?code:escape(code,true))+\"n
\"}return'
'+(escaped?code:escape(code,true))+\"n
n\"};Renderer.prototype.blockquote=function(quote){return\"
n\"+quote+\"
n\"};Renderer.prototype.html=function(html){return html};Renderer.prototype.heading=function(text,level,raw){return\"'+text+\"n\"};Renderer.prototype.hr=function(){return this.options.xhtml?\"
n\":\"
n\"};Renderer.prototype.list=function(body,ordered){var type=ordered?\"ol\":\"ul\";return\"<\"+type+\">n\"+body+\"n\"};Renderer.prototype.listitem=function(text){return\"
  • \"+text+\"
  • n\"};Renderer.prototype.paragraph=function(text){return\"

    \"+text+\"

    n\"};Renderer.prototype.table=function(header,body){return\"n\"+\"n\"+header+\"n\"+\"n\"+body+\"n\"+\"
    n\"};Renderer.prototype.tablerow=function(content){return\"n\"+content+\"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+\"n\"};Renderer.prototype.strong=function(text){return\"\"+text+\"\"};Renderer.prototype.em=function(text){return\"\"+text+\"\"};Renderer.prototype.codespan=function(text){return\"\"+text+\"\"};Renderer.prototype.br=function(){return this.options.xhtml?\"
    \":\"
    \"};Renderer.prototype.del=function(text){return\"\"+text+\"\"};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='
    \"+text+\"\";return out};Renderer.prototype.image=function(href,title,text){var out='\"'+text+'\"';if(title){out+='\":\">\";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/g,\">\").replace(/\"/g,\""\").replace(/'/g,\"'\")}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(;iAn error occured:

    \"+escape(e.message+\"\",true)+\"
    \"}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)}());
    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. > Note: > > You can pass an array into the `value` attribute, allowing you to select multiple options in a `select` tag: `