Skip to content
Snippets Groups Projects
This project is mirrored from https://github.com/facebook/react.git. Pull mirroring updated .
  1. Feb 28, 2025
  2. Feb 26, 2025
  3. Feb 25, 2025
  4. Feb 24, 2025
  5. Feb 22, 2025
    • Josh Story's avatar
      [Fizz] Responsive images should not be preloaded with link headers (#32445) · 9b042f9d
      Josh Story authored
      Link headers are optionally supported for cases where you prefer to send
      resource loading hints before you're ready to send the body of a
      request. While many resources can be correctly preloaded from a link
      header responsive images are currently not supported and end up
      preloading the default src rather than the correctly sized image. Until
      responsive images are supported React will not allow these images to
      preload as headers and will retain them to preload as HTML.
      
      closes: #32437
      9b042f9d
    • Sebastian Markbåge's avatar
      Add Example of a SwipeRecognizer (#32422) · 27ba5e8b
      Sebastian Markbåge authored
      Stacked on #32412.
      
      To effectively `useSwipeTransition` you need something to start and stop
      the gesture as well as triggering an Action.
      
      This adds an example Gesture Recognizer to the fixture. Instead of
      having this built-in to React itself, instead the idea is to leave this
      to various user space Component libraries. It can be done in different
      ways for different use cases. It could use JS driven or native
      ScrollTimeline or both.
      
      This example uses a native scroll with scroll snapping to two edges. If
      you swipe far enough to snap to the other edge, it triggers an Action at
      the end.
      
      This particular example uses a `position: sticky` to wrap the content of
      the Gesture Recognizer. This means that it's inert by itself. It doesn't
      scroll its content just like a plain JS recognizer using pointer events
      would. This is useful because it means that scrolling doesn't affect
      content before we start (the "scroll" event fires after scrolling has
      already started) so we don't have to both trying to start it earlier. It
      also means that scrolling doesn't affect the live content which can lead
      to unexpected effects on the View Transition.
      
      I find the inert recognizer the most useful pairing with
      `useSwipeTransition` but it's not the only way to do it. E.g. you can
      also have a scrollable surface that uses plain scrolling with snapping
      and then just progressively enhances swiping between steps.
      27ba5e8b
    • Sebastian Markbåge's avatar
      Allow passing range option to useSwipeTransition (#32412) · 662957cc
      Sebastian Markbåge authored
      Stacked on #32379
      
      Track the range offsets along the timeline where previous/current/next
      is. This can also be specified as an option. This lets you model more
      than three states along a timeline by clamping them and then updating
      the "current" as you go.
      
      It also allows specifying the "current" offset as something different
      than what it was when the gesture started such as if it has to start
      after scroll has already happened (such as what happens if you listen to
      the "scroll" event).
      662957cc
  6. Feb 21, 2025
    • Sebastian Markbåge's avatar
      Rerender useSwipeTransition when direction changes (#32379) · 88479c6f
      Sebastian Markbåge authored
      We can only render one direction at a time with View Transitions. When
      the direction changes we need to do another render in the new direction
      (returning previous or next).
      
      To determine direction we store the position we started at and anything
      moving to a lower value (left/up) is "previous" direction (`false`) and
      anything else is "next" (`true`) direction.
      
      For the very first render we won't know which direction you're going
      since you're still on the initial position. It's useful to start the
      render to allow the view transition to take control before anything
      shifts around so we start from the original position. This is not
      guaranteed though if the render suspends.
      
      For now we start the first render by guessing the direction such as if
      we know that prev/next are the same as current. With the upcoming auto
      start mode we can guess more accurately there before we start. We can
      also add explicit APIs to `startGesture` but ideally it wouldn't matter.
      Ideally we could just start after the first change in direction from the
      starting point.
      88479c6f
    • Sam Zhou's avatar
    • Jack Pope's avatar
      Revert "Ship enableFabricCompleteRootInCommitPhase (#32318)" (#32434) · 885532c1
      Jack Pope authored
      This reverts commit 8759c5c8 /
      https://github.com/facebook/react/pull/32318
      
      We discovered that the experiment setup for this was faulty and we need
      to re-run as a back test.
      885532c1
    • mofeiZ's avatar
      [compiler][playground] Upgrade to Next 15.2.0-canary.64 (#32428) · 5f31228d
      mofeiZ authored
      Upgrade compiler playground to use the newest nextjs release, which
      includes react compiler transform pipeline optimizations
      https://github.com/vercel/next.js/pull/75676/.
      
      Also made a drive-by fix to avoid the error `Cannot update a component
      ('Router') while rendering a different component ('StoreProvider'). To
      locate the bad setState() call inside 'StoreProvider', follow the stack
      trace as described in https://react.dev/link/setstate-in-render`. The
      bad setState came from `history.replaceState({}, '', \`#${hash}\`);`.
      
      Prior to this, playground ran side effects in a reducer (i.e. during
      render). These have now been moved an effect.
      5f31228d
  7. Feb 20, 2025
  8. Feb 19, 2025
  9. Feb 18, 2025
  10. Feb 17, 2025
  11. Feb 16, 2025
  12. Feb 14, 2025
    • Dawid Małecki's avatar
      Change TouchedViewDataAtPoint type in ReactNativeTypes to use supported by... · e670e72f
      Dawid Małecki authored
      Change TouchedViewDataAtPoint type in ReactNativeTypes to use supported by Flow tooling syntax (#32382)
      
      ## Summary
      
      The `flow-api-translator` from the `hermes` repo does not support flow
      type spreads. It is currently not able to digest the ReactNativeTypes
      file as it contains unsupported syntax. The simplest solution is to
      change the type of the `TouchedViewDataAtPoint` to equivalent, yet
      supported by the Flow tooling. In this case the intersection can be used
      as
      the `TouchedViewDataAtPoint` and `InspectorData` have no common
      property.
      
      ## How did you test this change?
      
      Run yarn flow native
      e670e72f
    • Sebastian Markbåge's avatar
      Add useSwipeTransition Hook Behind Experimental Flag (#32373) · a53da6ab
      Sebastian Markbåge authored
      This Hook will be used to drive a View Transition based on a gesture.
      
      ```js
      const [value, startGesture] = useSwipeTransition(prev, current, next);
      ```
      
      The `enableSwipeTransition` flag will depend on `enableViewTransition`
      flag but we may decide to ship them independently. This PR doesn't do
      anything interesting yet. There will be a lot more PRs to build out the
      actual functionality. This is just wiring up the plumbing for the new
      Hook.
      
      This first PR is mainly concerned with how the whole starts (and stops).
      The core API is the `startGesture` function (although there will be
      other conveniences added in the future). You can call this to start a
      gesture with a source provider. You can call this multiple times in one
      event to batch multiple Hooks listening to the same provider. However,
      each render can only handle one source provider at a time and so it does
      one render per scheduled gesture provider.
      
      This uses a separate `GestureLane` to drive gesture renders by marking
      the Hook as having an update on that lane. Then schedule a render. These
      renders should be blocking and in the same microtask as the
      `startGesture` to ensure it can block the paint. So it's similar to
      sync.
      
      It may not be possible to finish it synchronously e.g. if something
      suspends. If so, it just tries again later when it can like any other
      render. This can also happen because it also may not be possible to
      drive more than one gesture at a time like if we're limited to one View
      Transition per document. So right now you can only run one gesture at a
      time in practice.
      
      These renders never commit. This means that we can't clear the
      `GestureLane` the normal way. Instead, we have to clear only the root's
      `pendingLanes` if we don't have any new renders scheduled. Then wait
      until something else updates the Fiber after all gestures on it have
      stopped before it really clears.
      a53da6ab
    • Sebastian "Sebbie" Silbermann's avatar
      Enable owner stacks in Canary builds (#32053) · 32b0cad8
      Sebastian "Sebbie" Silbermann authored
      Pending internal decision to ship in Canary.
      Still off for FB builds.
      
      Docs: https://github.com/reactjs/react.dev/pull/7427
      32b0cad8
    • Sebastian "Sebbie" Silbermann's avatar
    • Sebastian "Sebbie" Silbermann's avatar
  13. Feb 13, 2025
    • LoganDark's avatar
      fix value formatting of proxies of class instances (#30880) · cbbe8666
      LoganDark authored
      For Hookstate Proxies of class instances, `data.constructor.name`
      returns `Proxy({})`, so use
      `Object.getPrototypeOf(data).constructor.name` instead, which works
      correctly from my testing.
      
      <!--
        Thanks for submitting a pull request!
      We appreciate you spending the time to work on these changes. Please
      provide enough information so that others can review your pull request.
      The three fields below are mandatory.
      
      Before submitting a pull request, please make sure the following is
      done:
      
      1. Fork [the repository](https://github.com/facebook/react) and create
      your branch from `main`.
        2. Run `yarn` in the repository root.
      3. If you've fixed a bug or added code that should be tested, add tests!
      4. Ensure the test suite passes (`yarn test`). Tip: `yarn test --watch
      TestName` is helpful in development.
      5. Run `yarn test --prod` to test in the production environment. It
      supports the same options as `yarn test`.
      6. If you need a debugger, run `yarn test --debug --watch TestName`,
      open `chrome://inspect`, and press "Inspect".
      7. Format your code with
      [prettier](https://github.com/prettier/prettier) (`yarn prettier`).
      8. Make sure your code lints (`yarn lint`). Tip: `yarn linc` to only
      check changed files.
        9. Run the [Flow](https://flowtype.org/) type checks (`yarn flow`).
        10. If you haven't already, complete the CLA.
      
      Learn more about contributing:
      https://reactjs.org/docs/how-to-contribute.html
      -->
      
      ## Summary
      
      React DevTools immediately bricks itself if you inspect any component
      that has a prop that is a Hookstate that wraps a class instance ...
      because these are proxies where `data.constructor.name` returns some
      un-cloneable object, but `Object.getPrototypeOf(data)` doesn't return
      `Object` (it returns the prototype of the class inside).
      
      ## How did you test this change?
      
      This part of the code has no associated tests at all.
      
      Technically,
      `packages/react-devtools-shared/src/__tests__/legacy/inspectElement-test.js`
      exists, but I tried `yarn test` and these tests aren't even executed
      anymore. I can't figure it out, so whatever.
      
      If you run this code:
      
      ```js
          class Class {}
          const instance = new Class();
      
          const instanceProxy = new Proxy(instance, {
            get(target, key, receiver) {
              if (key === 'constructor') {
                return { name: new Proxy({}, {}) };
              }
      
              return Reflect.get(target, key, receiver);
            },
          });
      ```
      
      then `instanceProxy.constructor.name` returns some proxy that cannot be
      cloned, but `Object.getPrototypeOf(instanceProxy).constructor.name`
      returns the correct value.
      
      This PR fixes the devtools to use
      `Object.getPrototypeOf(instanceProxy).constructor.name`.
      
      I modified my local copy of devtools to use this method and it fixed the
      bricking that I experienced.
      
      Related #29954
      cbbe8666