Skip to content

[compiler] Allow ref access in callbacks passed to event handler props#35062

Merged
josephsavona merged 3 commits intofacebook:mainfrom
kolvian:allow-ref-in-event-handler
Nov 14, 2025
Merged

[compiler] Allow ref access in callbacks passed to event handler props#35062
josephsavona merged 3 commits intofacebook:mainfrom
kolvian:allow-ref-in-event-handler

Conversation

@kolvian
Copy link
Copy Markdown
Contributor

@kolvian kolvian commented Nov 6, 2025

Summary

Fixes #35040. The React compiler incorrectly flags ref access within event handlers as ref access at render time. For example, this code would fail to compile with error "Cannot access refs during render":

  const onSubmit = async (data) => {
    const file = ref.current?.toFile(); // Incorrectly flagged as error
  };

  <form onSubmit={handleSubmit(onSubmit)}>

This is a false positive because any built-in DOM event handler is guaranteed not to run at render time. This PR only supports built-in event handlers because there are no guarantees that user-made event handlers will not run at render time.

How did you test this change?

I created 4 test fixtures which validate this change:

  • allow-ref-access-in-event-handler-wrapper.tsx - Sync handler test input
  • allow-ref-access-in-event-handler-wrapper.expect.md - Sync handler expected output
  • allow-ref-access-in-async-event-handler-wrapper.tsx - Async handler test input
  • allow-ref-access-in-async-event-handler-wrapper.expect.md - Async handler expected output

All linters and test suites also pass.

@meta-cla meta-cla Bot added the CLA Signed label Nov 6, 2025
@react-sizebot
Copy link
Copy Markdown

react-sizebot commented Nov 6, 2025

The size diff is too large to display in a single comment. The GitHub action for this pull request contains an artifact called 'sizebot-message.md' with the full message.

Generated by 🚫 dangerJS against afef137

@kolvian kolvian force-pushed the allow-ref-in-event-handler branch from 93f0ffe to afef137 Compare November 6, 2025 20:20
Copy link
Copy Markdown
Member

@josephsavona josephsavona left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! The approach here works in some cases, but it's encoding some important information — which values can be inferred as event handlers — in an-hoc way. The way we would typically handle this is by adding types to represent a concept, inferring the types appropriately in InferTypes, and then using the type information in later passes.

So the way to go here would be to add a BuiltinEventHandlerId shapeId (see ObjectShape.ts with all the BuiltIn...Id constants), then update InferTypes to infer the types of JsxExpression props as {kind: 'Function', shapeId: BuiltinEventHandlerId, ...} using similar logic to what you have here. Ie, for primitive tags where the prop is a named prop starting with "on".

Then, ValidateNoRefAccessInRender can allow ref-accessing functions to flow into expressions if the result is known to be an event handler. Then you can add an extra case into the logic at https://github.com/facebook/react/blob/main/compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateNoRefAccessInRender.ts#L521C21-L553, along the lines of

  const isRefLValue = isUseRefType(instr.lvalue.identifier);
+ const isEventHandlerLValue = isEventHandlerType(instr.lvalue.identifier);
...
  if (
    isRevLValue ||
+   isEventHandlerLValue ||
...

Finally, all of this should only be enabled behind a feature flag, which you can add in Environment.ts: enableInferEventHandlers, false by default. Put the logic in InferTypes behind this feature flag (the ValidateNoRefAccess changes will only take effect if the type is inferred, which it won't be w/o the feature).

Make sure to add // @ enableInferEventHandlers as the first line of each of your new test fixtures to enable the feature.

Comment thread packages/react-debug-tools/src/__tests__/ReactHooksInspection-test.js Outdated
Fixes a false positive where the compiler incorrectly flags ref access
in callbacks passed to event handler wrappers on built-in DOM elements.

For example, with react-hook-form:
  <form onSubmit={handleSubmit(onSubmit)}>

Where onSubmit accesses ref.current, this was incorrectly flagged as
"Cannot access refs during render". This is a false positive because
built-in DOM event handlers are guaranteed by React to only execute in
response to actual events, never during render.

This fix only relaxes validation for built-in DOM elements (not custom
components) to maintain safety. Custom components could call their onFoo
props during render, which would violate ref access rules.

Adds four test fixtures demonstrating allowed and disallowed patterns.

Issue: facebook#35040
@kolvian kolvian force-pushed the allow-ref-in-event-handler branch 3 times, most recently from 06400ca to 78d7f9c Compare November 9, 2025 05:08
@kolvian
Copy link
Copy Markdown
Contributor Author

kolvian commented Nov 9, 2025

Thanks for the detailed review! I made some changes, was just wondering if the current string-based check is robust enough for the React compiler or if I should find some other checking method. Some alternatives I explored were type annotation-based checks (but these aren't available by the time the InferTypes runs) and hardcoded lists of supported event handlers, but these aren't extensible and would need to be maintained. I also added a check that makes sure that the component isn't a web component (would have a hyphen), which is the only edge case I can think of. If there are any others I can definitely include them.

@kolvian kolvian requested a review from josephsavona November 10, 2025 22:09
@Samdevelop25

This comment was marked as spam.

@@ -0,0 +1,28 @@
// @enableInferEventHandlers
// @validateRefAccessDuringRender
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just noticed this - all the @ pragmas need to be on the first line (also the same fix in other files). I think the reason you're getting errors is that validateRefAccessDuringRender is on by default

@josephsavona
Copy link
Copy Markdown
Member

We reviewed as a team and are aligned on the direction here, i actually came here to merge and noticed one small thing to fix first, see above comment

Copy link
Copy Markdown
Member

@josephsavona josephsavona left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

accepting but please address the comment so that we can merge

@kolvian kolvian force-pushed the allow-ref-in-event-handler branch 2 times, most recently from 053c95b to c371167 Compare November 14, 2025 01:25
@kolvian kolvian force-pushed the allow-ref-in-event-handler branch from c371167 to 42f3da5 Compare November 14, 2025 01:47
@kolvian
Copy link
Copy Markdown
Contributor Author

kolvian commented Nov 14, 2025

accepting but please address the comment so that we can merge

should be fixed now @josephsavona

@josephsavona josephsavona merged commit 21f2824 into facebook:main Nov 14, 2025
17 of 18 checks passed
@josephsavona
Copy link
Copy Markdown
Member

Thanks again!

github-actions Bot pushed a commit that referenced this pull request Nov 14, 2025
#35062)

## Summary

Fixes #35040. The React compiler incorrectly flags ref access within
event handlers as ref access at render time. For example, this code
would fail to compile with error "Cannot access refs during render":

```tsx
  const onSubmit = async (data) => {
    const file = ref.current?.toFile(); // Incorrectly flagged as error
  };

  <form onSubmit={handleSubmit(onSubmit)}>
```
This is a false positive because any built-in DOM event handler is
guaranteed not to run at render time. This PR only supports built-in
event handlers because there are no guarantees that user-made event
handlers will not run at render time.

## How did you test this change?

I created 4 test fixtures which validate this change:
* allow-ref-access-in-event-handler-wrapper.tsx - Sync handler test
input
* allow-ref-access-in-event-handler-wrapper.expect.md - Sync handler
expected output
* allow-ref-access-in-async-event-handler-wrapper.tsx - Async handler
test input
* allow-ref-access-in-async-event-handler-wrapper.expect.md - Async
handler expected output

All linters and test suites also pass.

DiffTrain build for [21f2824](21f2824)
github-actions Bot pushed a commit that referenced this pull request Nov 14, 2025
#35062)

## Summary

Fixes #35040. The React compiler incorrectly flags ref access within
event handlers as ref access at render time. For example, this code
would fail to compile with error "Cannot access refs during render":

```tsx
  const onSubmit = async (data) => {
    const file = ref.current?.toFile(); // Incorrectly flagged as error
  };

  <form onSubmit={handleSubmit(onSubmit)}>
```
This is a false positive because any built-in DOM event handler is
guaranteed not to run at render time. This PR only supports built-in
event handlers because there are no guarantees that user-made event
handlers will not run at render time.

## How did you test this change?

I created 4 test fixtures which validate this change:
* allow-ref-access-in-event-handler-wrapper.tsx - Sync handler test
input
* allow-ref-access-in-event-handler-wrapper.expect.md - Sync handler
expected output
* allow-ref-access-in-async-event-handler-wrapper.tsx - Async handler
test input
* allow-ref-access-in-async-event-handler-wrapper.expect.md - Async
handler expected output

All linters and test suites also pass.

DiffTrain build for [21f2824](21f2824)
manNomi pushed a commit to manNomi/react that referenced this pull request Nov 15, 2025
facebook#35062)

## Summary

Fixes facebook#35040. The React compiler incorrectly flags ref access within
event handlers as ref access at render time. For example, this code
would fail to compile with error "Cannot access refs during render":

```tsx
  const onSubmit = async (data) => {
    const file = ref.current?.toFile(); // Incorrectly flagged as error
  };

  <form onSubmit={handleSubmit(onSubmit)}>
```
This is a false positive because any built-in DOM event handler is
guaranteed not to run at render time. This PR only supports built-in
event handlers because there are no guarantees that user-made event
handlers will not run at render time.

## How did you test this change?

I created 4 test fixtures which validate this change:
* allow-ref-access-in-event-handler-wrapper.tsx - Sync handler test
input
* allow-ref-access-in-event-handler-wrapper.expect.md - Sync handler
expected output
* allow-ref-access-in-async-event-handler-wrapper.tsx - Async handler
test input
* allow-ref-access-in-async-event-handler-wrapper.expect.md - Async
handler expected output

All linters and test suites also pass.
github-actions Bot pushed a commit to code/lib-react that referenced this pull request Nov 16, 2025
facebook#35062)

## Summary

Fixes facebook#35040. The React compiler incorrectly flags ref access within
event handlers as ref access at render time. For example, this code
would fail to compile with error "Cannot access refs during render":

```tsx
  const onSubmit = async (data) => {
    const file = ref.current?.toFile(); // Incorrectly flagged as error
  };

  <form onSubmit={handleSubmit(onSubmit)}>
```
This is a false positive because any built-in DOM event handler is
guaranteed not to run at render time. This PR only supports built-in
event handlers because there are no guarantees that user-made event
handlers will not run at render time.

## How did you test this change?

I created 4 test fixtures which validate this change:
* allow-ref-access-in-event-handler-wrapper.tsx - Sync handler test
input
* allow-ref-access-in-event-handler-wrapper.expect.md - Sync handler
expected output
* allow-ref-access-in-async-event-handler-wrapper.tsx - Async handler
test input
* allow-ref-access-in-async-event-handler-wrapper.expect.md - Async
handler expected output

All linters and test suites also pass.

DiffTrain build for [21f2824](facebook@21f2824)
736-c41-2c1-e464fc974 pushed a commit to Swiss-Armed-Forces/Loom that referenced this pull request Apr 27, 2026
This MR contains the following updates:

| Package | Type | Update | Change | OpenSSF |
|---|---|---|---|---|
| [@typescript-eslint/eslint-plugin](https://typescript-eslint.io/packages/eslint-plugin) ([source](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin)) | devDependencies | minor | [`8.58.2` → `8.59.0`](https://renovatebot.com/diffs/npm/@typescript-eslint%2feslint-plugin/8.58.2/8.59.0) | [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/typescript-eslint/typescript-eslint/badge)](https://securityscorecards.dev/viewer/?uri=github.com/typescript-eslint/typescript-eslint) |
| [@typescript-eslint/parser](https://typescript-eslint.io/packages/parser) ([source](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser)) | devDependencies | minor | [`8.58.2` → `8.59.0`](https://renovatebot.com/diffs/npm/@typescript-eslint%2fparser/8.58.2/8.59.0) | [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/typescript-eslint/typescript-eslint/badge)](https://securityscorecards.dev/viewer/?uri=github.com/typescript-eslint/typescript-eslint) |
| [ajv](https://ajv.js.org) ([source](https://github.com/ajv-validator/ajv)) | dependencies | minor | [`8.18.0` → `8.20.0`](https://renovatebot.com/diffs/npm/ajv/8.18.0/8.20.0) | [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/ajv-validator/ajv/badge)](https://securityscorecards.dev/viewer/?uri=github.com/ajv-validator/ajv) |
| [eslint-plugin-react-hooks](https://react.dev/) ([source](https://github.com/facebook/react/tree/HEAD/packages/eslint-plugin-react-hooks)) | devDependencies | minor | [`7.0.1` → `7.1.1`](https://renovatebot.com/diffs/npm/eslint-plugin-react-hooks/7.0.1/7.1.1) | [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/facebook/react/badge)](https://securityscorecards.dev/viewer/?uri=github.com/facebook/react) |
| [react-toastify](https://github.com/fkhadra/react-toastify) | dependencies | minor | [`11.0.5` → `11.1.0`](https://renovatebot.com/diffs/npm/react-toastify/11.0.5/11.1.0) | [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/fkhadra/react-toastify/badge)](https://securityscorecards.dev/viewer/?uri=github.com/fkhadra/react-toastify) |
| [typescript-eslint](https://typescript-eslint.io/packages/typescript-eslint) ([source](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/typescript-eslint)) | devDependencies | minor | [`8.58.2` → `8.59.0`](https://renovatebot.com/diffs/npm/typescript-eslint/8.58.2/8.59.0) | [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/typescript-eslint/typescript-eslint/badge)](https://securityscorecards.dev/viewer/?uri=github.com/typescript-eslint/typescript-eslint) |
| [vite-plugin-static-copy](https://github.com/sapphi-red/vite-plugin-static-copy) | devDependencies | minor | [`4.0.1` → `4.1.0`](https://renovatebot.com/diffs/npm/vite-plugin-static-copy/4.0.1/4.1.0) | [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/sapphi-red/vite-plugin-static-copy/badge)](https://securityscorecards.dev/viewer/?uri=github.com/sapphi-red/vite-plugin-static-copy) |

---

### Release Notes

<details>
<summary>typescript-eslint/typescript-eslint (@&#8203;typescript-eslint/eslint-plugin)</summary>

### [`v8.59.0`](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/CHANGELOG.md#8590-2026-04-20)

[Compare Source](typescript-eslint/typescript-eslint@v8.58.2...v8.59.0)

##### 🚀 Features

- **eslint-plugin:** \[no-unnecessary-type-assertion] report more cases based on assignability ([#&#8203;11789](typescript-eslint/typescript-eslint#11789))

##### ❤️ Thank You

- Ulrich Stark

See [GitHub Releases](https://github.com/typescript-eslint/typescript-eslint/releases/tag/v8.59.0) for more information.

You can read about our [versioning strategy](https://typescript-eslint.io/users/versioning) and [releases](https://typescript-eslint.io/users/releases) on our website.

</details>

<details>
<summary>typescript-eslint/typescript-eslint (@&#8203;typescript-eslint/parser)</summary>

### [`v8.59.0`](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/parser/CHANGELOG.md#8590-2026-04-20)

[Compare Source](typescript-eslint/typescript-eslint@v8.58.2...v8.59.0)

This was a version bump only for parser to align it with other projects, there were no code changes.

See [GitHub Releases](https://github.com/typescript-eslint/typescript-eslint/releases/tag/v8.59.0) for more information.

You can read about our [versioning strategy](https://typescript-eslint.io/users/versioning) and [releases](https://typescript-eslint.io/users/releases) on our website.

</details>

<details>
<summary>ajv-validator/ajv (ajv)</summary>

### [`v8.20.0`](https://github.com/ajv-validator/ajv/releases/tag/v8.20.0)

[Compare Source](ajv-validator/ajv@v8.18.0...v8.20.0)

#### What's Changed

- fix: add support for node 22/24, drop node 16/21 by [@&#8203;jasoniangreen](https://github.com/jasoniangreen) in [#&#8203;2580](ajv-validator/ajv#2580)
- fix: add ES2022.RegExp for RegExpIndicesArray by [@&#8203;SignpostMarv](https://github.com/SignpostMarv) in [#&#8203;2604](ajv-validator/ajv#2604)

**Full Changelog**: <ajv-validator/ajv@v8.19.0...v8.20.0>

</details>

<details>
<summary>facebook/react (eslint-plugin-react-hooks)</summary>

### [`v7.1.1`](https://github.com/facebook/react/blob/HEAD/packages/eslint-plugin-react-hooks/CHANGELOG.md#711)

[Compare Source](https://github.com/facebook/react/compare/eslint-plugin-react-hooks@7.1.0...eslint-plugin-react-hooks@7.1.1)

**Note:** 7.1.0 accidentally removed the `component-hook-factories` rule, causing errors for users who referenced it in their ESLint config. This is now fixed.

- Add deprecated no-op `component-hook-factories` rule for backwards compatibility. ([@&#8203;mofeiZ](https://github.com/mofeiZ) in [#&#8203;36307](facebook/react#36307))

### [`v7.1.0`](https://github.com/facebook/react/blob/HEAD/packages/eslint-plugin-react-hooks/CHANGELOG.md#710)

[Compare Source](https://github.com/facebook/react/compare/408b38ef7304faf022d2a37110c57efce12c6bad...eslint-plugin-react-hooks@7.1.0)

This release adds ESLint v10 support, improves performance by skipping compilation for non-React files, and includes compiler lint improvements including better `set-state-in-effect` detection, improved ref validation, and more helpful error reporting.

- Add ESLint v10 support. ([@&#8203;azat-io](https://github.com/azat-io) in [#&#8203;35720](facebook/react#35720))
- Skip compilation for non-React files to improve performance. ([@&#8203;josephsavona](https://github.com/josephsavona) in [#&#8203;35589](facebook/react#35589))
- Fix exhaustive deps bug with Flow type casting. ([@&#8203;jorge-cab](https://github.com/jorge-cab) in [#&#8203;35691](facebook/react#35691))
- Fix `useEffectEvent` checks in component syntax. ([@&#8203;jbrown215](https://github.com/jbrown215) in [#&#8203;35041](facebook/react#35041))
- Improved `set-state-in-effect` validation with fewer false negatives. ([@&#8203;jorge-cab](https://github.com/jorge-cab) in [#&#8203;35134](facebook/react#35134), [@&#8203;josephsavona](https://github.com/josephsavona) in [#&#8203;35147](facebook/react#35147), [@&#8203;jackpope](https://github.com/jackpope) in [#&#8203;35214](facebook/react#35214), [@&#8203;chesnokov-tony](https://github.com/chesnokov-tony) in [#&#8203;35419](facebook/react#35419), [@&#8203;jsleitor](https://github.com/jsleitor) in [#&#8203;36107](facebook/react#36107))
- Improved ref validation for non-mutating functions and event handler props. ([@&#8203;josephsavona](https://github.com/josephsavona) in [#&#8203;35893](facebook/react#35893), [@&#8203;kolvian](https://github.com/kolvian) in [#&#8203;35062](facebook/react#35062))
- Compiler now reports all errors instead of stopping at the first. ([@&#8203;josephsavona](https://github.com/josephsavona) in [#&#8203;35873](https://github.com/facebook/react/pull/35873)–[#&#8203;35884](https://github.com/facebook/react/pull/35884))
- Improved source locations and error display in compiler diagnostics. ([@&#8203;nathanmarks](https://github.com/nathanmarks) in [#&#8203;35348](facebook/react#35348), [@&#8203;josephsavona](https://github.com/josephsavona) in [#&#8203;34963](facebook/react#34963))

</details>

<details>
<summary>fkhadra/react-toastify (react-toastify)</summary>

### [`v11.1.0`](https://github.com/fkhadra/react-toastify/releases/tag/v11.1.0)

[Compare Source](fkhadra/react-toastify@v11.0.5...v11.1.0)

### Release Notes

#### Features

- **CSP nonce support.** `<ToastContainer nonce={...}>` applies the nonce to the
  injected `<style>` tag. Closes [#&#8203;1209](fkhadra/react-toastify#1209).

#### Fixes

- `onChange` fires `status: 'removed'` synchronously on `toast.dismiss()` instead
  of after the exit animation — observers (incl. `useNotificationCenter`) now
  see correctly ordered events. Also guards against double-`onClose`. Closes [#&#8203;1275](fkhadra/react-toastify#1275).
- Touch drag no longer re-pauses the toast on release — the old check compared a
  PointerEvent against `'touchend'`, which never matched. Closes [#&#8203;1217](fkhadra/react-toastify#1217).
- Vertical drag now visually moves the toast (`--y` gets a unit). Thanks
  [@&#8203;janpaepke](https://github.com/janpaepke), [#&#8203;1277](fkhadra/react-toastify#1277).
- Stacked scale is clamped at 0.5, preventing zero/negative scale in deep
  stacks. Closes [#&#8203;1171](fkhadra/react-toastify#1171), [#&#8203;1174](fkhadra/react-toastify#1174).
- Stacked container respects mobile `100vw` again. Closes [#&#8203;1234](fkhadra/react-toastify#1234).

#### Accessibility

- `role="progressbar"` now includes `aria-valuenow`, `aria-valuemin`, `aria-valuemax`.
  Thanks [@&#8203;singhankit001](https://github.com/singhankit001), [#&#8203;1283](fkhadra/react-toastify#1283). Closes [#&#8203;1259](fkhadra/react-toastify#1259).

#### Internal

- Migrated to a pnpm workspace (`pnpm link .` no longer required for contributors).
  Publish layout unchanged — addon still ships inside the main package.
- CSS now injected at mount via `useStyleSheet` (prerequisite for `nonce`).
- Dep bumps: TypeScript 6, Vite 8, Cypress 15, React 19.2, plus the rest.
- CI: `upload-artifact` v3 → v4.

Thanks to [@&#8203;janpaepke](https://github.com/janpaepke), [@&#8203;singhankit001](https://github.com/singhankit001), and reporters of the fixed issues.

</details>

<details>
<summary>typescript-eslint/typescript-eslint (typescript-eslint)</summary>

### [`v8.59.0`](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/typescript-eslint/CHANGELOG.md#8590-2026-04-20)

[Compare Source](typescript-eslint/typescript-eslint@v8.58.2...v8.59.0)

This was a version bump only for typescript-eslint to align it with other projects, there were no code changes.

See [GitHub Releases](https://github.com/typescript-eslint/typescript-eslint/releases/tag/v8.59.0) for more information.

You can read about our [versioning strategy](https://typescript-eslint.io/users/versioning) and [releases](https://typescript-eslint.io/users/releases) on our website.

</details>

<details>
<summary>sapphi-red/vite-plugin-static-copy (vite-plugin-static-copy)</summary>

### [`v4.1.0`](https://github.com/sapphi-red/vite-plugin-static-copy/blob/HEAD/CHANGELOG.md#410)

[Compare Source](https://github.com/sapphi-red/vite-plugin-static-copy/compare/vite-plugin-static-copy@4.0.1...vite-plugin-static-copy@4.1.0)

##### Minor Changes

- [#&#8203;251](sapphi-red/vite-plugin-static-copy#251) [`7672842`](sapphi-red/vite-plugin-static-copy@7672842) Thanks [@&#8203;sapphi-red](https://github.com/sapphi-red)! - Add `name` property to the `rename` object form and allow rename functions to return a `RenameObject`. The `name` property replaces the file's basename (filename + extension), and can be combined with `stripBase` to both flatten directory structure and rename the file in one step. Rename functions can now return `{ name, stripBase }` objects instead of only strings, making it easier to declaratively control output paths from dynamic rename logic.

  ```js
  // node_modules/lib/dist/index.js → vendor/lib.js
  { src: 'node_modules/lib/dist/index.js', dest: 'vendor', rename: { name: 'lib.js', stripBase: true } }

  // src/pages/events/test.html → dist/events/index.html
  { src: 'src/pages/**/*.html', dest: 'dist/', rename: { stripBase: 2, name: 'index.html' } }
  ```

</details>

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xMjkuMCIsInVwZGF0ZWRJblZlciI6IjQzLjE0MS4zIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJkZXBlbmRlbmNpZXMiLCJyZW5vdmF0ZSJdfQ==-->

See merge request swiss-armed-forces/cyber-command/cea/loom!480

Co-authored-by: Loom MR Pipeline Trigger <group_103951964_bot_9504bb8dead6d4e406ad817a607f24be@noreply.gitlab.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Getting Cannot access refs during render error from event handler.

4 participants