ObserveArray.map() tries to convert JSX into proxies
- Dominant language
- JavaScript
- Stars
- 42
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Description
When the `map()` function is called on a `ObserveArray` it tries to convert all the items in it into Proxies. This is not necessary when the map is returning JSX.
ex:
```js
{todos.map(todo => (
))}
```
Having to convert the JSX into proxies wastes time and isn't necessary.
A solution was discussed whereby from ylem we override the `can-observe` function which tells `map()` to do this. We can first check if the contents are JSX, if so we don't convert them to proxies, otherwise we just pass it off to the original `can-observe` function.
Something like this:
```js
const makeObserve = require('can-observe/src/-make-observe');
const React = require('react');
const observe = makeObserve.observe;
makeObserve.observe = function(input) {
if (React.isValidElement(input)) {
return input;
}
return observe(input);
};
```
Contributor guide
Assessment
This issue has not been assessed yet.