BuilderIO / BuilderIO/builder

Localized tests trigger useComputed$ mutation state warnings

Open
#4,136 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
8.8k
Forks
1.2k
Avg merge
1d 6h
Merged PRs (30d)
17

Description

If you mark a Text field as Localizable and perform an SSR load with sdk-qwik, you'll get a screen full of warnings about mutating state inside useComputed$ and it makes it very hard to read/debug as conosle is just spammed with them.

This line is mutating state and should probably be rewritten to be immutably friendly by returning a new object:
https://github.com/BuilderIO/builder/blob/912bfa481d403a6b2cc7e2ae7d3d0cc6f4ea47f8/packages/sdks/src/functions/extract-localized-values.ts#L53-L56

**Warning from 1x localized string:**
```
QWIK WARN State mutation inside useComputed$() is an antipattern. Use useTask$() instead MockElement {
nodeType: 111,
_qc_: {
'$flags$': 12,
'$id$': '',
'$element$': [Circular *1],
'$refMap$': [],
li: [],
'$tasks$': [ [Task], [Task] ],
'$seq$': [ [Object], [SignalImpl] ],
'$slots$': [],
'$scopeIds$': null,
'$appendStyles$': null,
'$props$': {
block: [Object],
'$$linkComponent': [SignalDerived],
'$$context': [SignalDerived],
'$$registeredComponents': [SignalDerived],
[Symbol(IMMUTABLE)]: [Object]
},
'$vdom$': null,
'$componentQrl$': [AsyncFunction: qrl2] {
getSymbol: [Function: getSymbol],
getHash: [Function: getHash],
getCaptured: [Function: getCaptured],
resolve: [AsyncFunction: resolve],
'$resolveLazy$': [Function: resolveLazy],
'$setContainer$': [Function: setContainer],
'$chunk$': null,
'$symbol$': 'Block_component_nnPv0RY0U0k',
'$refSymbol$': null,
'$hash$': 'nnPv0RY0U0k',
getFn: [Function: invokeFn],
'$capture$': null,
'$captureRef$': [],
dev: [Object],
resolved: [Function: Block_component_nnPv0RY0U0k]
},
'$contexts$': null,
'$dynamicSlots$': null,
'$parentCtx$': {
'$flags$': 0,
'$id$': '',
'$element$': [MockElement],
'$refMap$': [],
li: [],
'$tasks$': null,
'$seq$': null,
'$slots$': null,
'$scopeIds$': null,
'$appendStyles$': null,
'$props$': null,
'$vdom$': null,
'$componentQrl$': null,
'$contexts$': null,
'$dynamicSlots$': null,
'$parentCtx$': [Object],
'$realParentCtx$': undefined
},
'$realParentCtx$': {
'$flags$': 4,
'$id$': 'm',
'$element$': [MockElement],
'$refMap$': [],
li: [],
'$tasks$': null,
'$seq$': [Array],
'$slots$': [],
'$scopeIds$': null,
'$appendStyles$': null,
'$props$': [Object],
'$vdom$': null,
'$componentQrl$': [AsyncFunction],
'$contexts$': null,
'$dynamicSlots$': null,
'$parentCtx$': [Object],
'$realParentCtx$': [Object]
}
}
}

```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.