Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: added a note to component's children section #1600

Merged
merged 6 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/stupid-pants-hammer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@builder.io/mitosis': patch
---

added note on children prop to inform about children prop iteration
samijaber marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -5321,7 +5321,7 @@ exports[`Alpine.js > jsx > Typescript Test > signalsOnUpdate 1`] = `
</style>
<div class=\\"test div\\" x-data=\\"myBasicComponent()\\">
<span x-html=\\"id\\"></span>
<span x-html=\\"foo.bar.baz\\"></span>
<span x-html=\\"foo.value.bar.baz\\"></span>
</div>
<script>
document.addEventListener(\\"alpine:init\\", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13288,7 +13288,7 @@ type Props = {
@Component({
selector: \\"my-basic-component\\",
template: \`
<div class=\\"test div\\">{{id}} {{foo.bar.baz}}</div>
<div class=\\"test div\\">{{id}} {{foo.value.bar.baz}}</div>
\`,
styles: [
\`
Expand All @@ -13308,7 +13308,7 @@ export default class MyBasicComponent {
ngOnChanges(changes: SimpleChanges) {
if (typeof window !== \\"undefined\\") {
console.log(\\"props.id changed\\", this.id);
console.log(\\"props.foo.value.bar.baz changed\\", this.foo.bar.baz);
console.log(\\"props.foo.value.bar.baz changed\\", this.foo.value.bar.baz);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13500,7 +13500,7 @@ type Props = {
@Component({
selector: \\"my-basic-component\\",
template: \`
<div class=\\"test div\\">{{id}} {{foo.bar.baz}}</div>
<div class=\\"test div\\">{{id}} {{foo.value.bar.baz}}</div>
\`,
styles: [
\`
Expand All @@ -13520,7 +13520,7 @@ export default class MyBasicComponent {
ngOnChanges(changes: SimpleChanges) {
if (typeof window !== \\"undefined\\") {
console.log(\\"props.id changed\\", this.id);
console.log(\\"props.foo.value.bar.baz changed\\", this.foo.bar.baz);
console.log(\\"props.foo.value.bar.baz changed\\", this.foo.value.bar.baz);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13712,7 +13712,7 @@ type Props = {
@Component({
selector: \\"my-basic-component\\",
template: \`
<div class=\\"test div\\">{{id}} {{foo.bar.baz}}</div>
<div class=\\"test div\\">{{id}} {{foo.value.bar.baz}}</div>
\`,
styles: [
\`
Expand All @@ -13732,7 +13732,7 @@ export default class MyBasicComponent {
ngOnChanges(changes: SimpleChanges) {
if (typeof window !== \\"undefined\\") {
console.log(\\"props.id changed\\", this.id);
console.log(\\"props.foo.value.bar.baz changed\\", this.foo.bar.baz);
console.log(\\"props.foo.value.bar.baz changed\\", this.foo.value.bar.baz);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11939,7 +11939,7 @@ type Props = {
@Component({
selector: \\"my-basic-component\\",
template: \`
<div class=\\"test div\\">{{id}} {{foo.bar.baz}}</div>
<div class=\\"test div\\">{{id}} {{foo.value.bar.baz}}</div>
\`,
styles: [
\`
Expand All @@ -11956,7 +11956,7 @@ export default class MyBasicComponent {
ngOnChanges(changes: SimpleChanges) {
if (typeof window !== \\"undefined\\") {
console.log(\\"props.id changed\\", this.id);
console.log(\\"props.foo.value.bar.baz changed\\", this.foo.bar.baz);
console.log(\\"props.foo.value.bar.baz changed\\", this.foo.value.bar.baz);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25036,7 +25036,7 @@ type Props = {
@Component({
selector: \\"my-basic-component\\",
template: \`
<div class=\\"test div\\">{{id}} {{foo.bar.baz}}</div>
<div class=\\"test div\\">{{id}} {{foo.value.bar.baz}}</div>
\`,
styles: [
\`
Expand All @@ -25056,7 +25056,7 @@ export default class MyBasicComponent {
ngOnChanges(changes: SimpleChanges) {
if (typeof window !== \\"undefined\\") {
console.log(\\"props.id changed\\", this.id);
console.log(\\"props.foo.value.bar.baz changed\\", this.foo.bar.baz);
console.log(\\"props.foo.value.bar.baz changed\\", this.foo.value.bar.baz);
}
}
}
Expand Down Expand Up @@ -25086,7 +25086,7 @@ type Props = {
@Component({
selector: \\"my-basic-component\\",
template: \`
<div class=\\"test div\\">{{id}} {{foo.bar.baz}}</div>
<div class=\\"test div\\">{{id}} {{foo.value.bar.baz}}</div>
\`,
styles: [
\`
Expand All @@ -25108,7 +25108,7 @@ export default class MyBasicComponent {
ngOnChanges(changes: SimpleChanges) {
if (typeof window !== \\"undefined\\") {
console.log(\\"props.id changed\\", this.id);
console.log(\\"props.foo.value.bar.baz changed\\", this.foo.bar.baz);
console.log(\\"props.foo.value.bar.baz changed\\", this.foo.value.bar.baz);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/__tests__/__snapshots__/html.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -13168,7 +13168,7 @@ exports[`Html > jsx > Typescript Test > showWithRootText 1`] = `
exports[`Html > jsx > Typescript Test > signalsOnUpdate 1`] = `
"<div class=\\"test div\\">
<template data-el=\\"div-1\\"><!-- props.id --></template>
<template data-el=\\"div-2\\"><!-- props.foo.bar.baz --></template>
<template data-el=\\"div-2\\"><!-- props.foo.value.bar.baz --></template>
</div>
<style>
.div {
Expand Down Expand Up @@ -13203,13 +13203,13 @@ exports[`Html > jsx > Typescript Test > signalsOnUpdate 1`] = `
});

document.querySelectorAll(\\"[data-el='div-2']\\").forEach((el) => {
renderTextNode(el, props.foo.bar.baz);
renderTextNode(el, props.foo.value.bar.baz);
});

destroyAnyNodes();

console.log(\\"props.id changed\\", props.id);
console.log(\\"props.foo.value.bar.baz changed\\", props.foo.bar.baz);
console.log(\\"props.foo.value.bar.baz changed\\", props.foo.value.bar.baz);

pendingUpdate = false;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/__tests__/__snapshots__/lit.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8432,7 +8432,7 @@ export default class MyBasicComponent extends LitElement {

updated() {
console.log(\\"props.id changed\\", this.id);
console.log(\\"props.foo.value.bar.baz changed\\", this.foo.bar.baz);
console.log(\\"props.foo.value.bar.baz changed\\", this.foo.value.bar.baz);
}

render() {
Expand All @@ -8441,7 +8441,7 @@ export default class MyBasicComponent extends LitElement {
padding: 10px;
}
</style>
<div>\${this.id} \${this.foo.bar.baz}</div>
<div>\${this.id} \${this.foo.value.bar.baz}</div>

\`;
}
Expand Down
9 changes: 6 additions & 3 deletions packages/core/src/__tests__/__snapshots__/marko.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4804,16 +4804,19 @@ exports[`Marko > jsx > Typescript Test > signalsOnUpdate 1`] = `
"class {
onRender() {
console.log(\\"props.id changed\\", this.input.id);
console.log(\\"props.foo.value.bar.baz changed\\", this.input.foo.bar.baz);
console.log(
\\"props.foo.value.bar.baz changed\\",
this.input.foo.value.bar.baz
);
}
}

style {
.div-52492278 {
.div-70a61356 {
padding: 10px;
}
}
<div class=\\"test div-52492278\\">\${input.id} \${input.foo.bar.baz}</div>"
<div class=\\"test div-70a61356\\">\${input.id} \${input.foo.value.bar.baz}</div>"
`;

exports[`Marko > jsx > Typescript Test > spreadAttrs 1`] = `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19602,8 +19602,8 @@ import { useEffect } from \\"react\\";
function MyBasicComponent(props) {
useEffect(() => {
console.log(\\"props.id changed\\", props.id);
console.log(\\"props.foo.value.bar.baz changed\\", props.foo.bar.baz);
}, [props.id, props.foo.bar.baz]);
console.log(\\"props.foo.value.bar.baz changed\\", props.foo.value.bar.baz);
}, [props.id, props.foo.value.bar.baz]);

return (
<div
Expand All @@ -19613,7 +19613,7 @@ function MyBasicComponent(props) {
}}
>
{props.id}
{props.foo.bar.baz}
{props.foo.value.bar.baz}
</div>
);
}
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/__tests__/__snapshots__/preact.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6991,14 +6991,14 @@ type Props = {
function MyBasicComponent(props: Props) {
useEffect(() => {
console.log(\\"props.id changed\\", props.id);
console.log(\\"props.foo.value.bar.baz changed\\", props.foo.bar.baz);
}, [props.id, props.foo.bar.baz]);
console.log(\\"props.foo.value.bar.baz changed\\", props.foo.value.bar.baz);
}, [props.id, props.foo.value.bar.baz]);

return (
<Fragment>
<div className=\\"test div\\">
{props.id}
{props.foo.bar.baz}
{props.foo.value.bar.baz}
</div>
<style jsx>{\`
.div {
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/__tests__/__snapshots__/qwik.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8480,15 +8480,15 @@ export const MyBasicComponent = component$((props: Props) => {

useTask$(({ track }) => {
track(() => props.id);
track(() => props.foo.bar.baz);
track(() => props.foo.value.bar.baz);
console.log(\\"props.id changed\\", props.id);
console.log(\\"props.foo.value.bar.baz changed\\", props.foo.bar.baz);
console.log(\\"props.foo.value.bar.baz changed\\", props.foo.value.bar.baz);
});

return (
<div class=\\"test div-MyBasicComponent\\">
{props.id}
{props.foo.bar.baz}
{props.foo.value.bar.baz}
</div>
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9613,13 +9613,13 @@ type Props = {
function MyBasicComponent(props: Props) {
useEffect(() => {
console.log(\\"props.id changed\\", props.id);
console.log(\\"props.foo.value.bar.baz changed\\", props.foo.bar.baz);
}, [props.id, props.foo.bar.baz]);
console.log(\\"props.foo.value.bar.baz changed\\", props.foo.value.bar.baz);
}, [props.id, props.foo.value.bar.baz]);

return (
<View style={styles.view1}>
<Text>{props.id}</Text>
<Text>{props.foo.bar.baz}</Text>
<Text>{props.foo.value.bar.baz}</Text>
</View>
);
}
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/__tests__/__snapshots__/react.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6807,14 +6807,14 @@ type Props = {
function MyBasicComponent(props: Props) {
useEffect(() => {
console.log(\\"props.id changed\\", props.id);
console.log(\\"props.foo.value.bar.baz changed\\", props.foo.bar.baz);
}, [props.id, props.foo.bar.baz]);
console.log(\\"props.foo.value.bar.baz changed\\", props.foo.value.bar.baz);
}, [props.id, props.foo.value.bar.baz]);

return (
<>
<div className=\\"test div\\">
{props.id}
{props.foo.bar.baz}
{props.foo.value.bar.baz}
</div>
<style jsx>{\`
.div {
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/__tests__/__snapshots__/rsc.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6265,14 +6265,14 @@ type Props = {
function MyBasicComponent(props: Props) {
useEffect(() => {
console.log(\\"props.id changed\\", props.id);
console.log(\\"props.foo.value.bar.baz changed\\", props.foo.bar.baz);
}, [props.id, props.foo.bar.baz]);
console.log(\\"props.foo.value.bar.baz changed\\", props.foo.value.bar.baz);
}, [props.id, props.foo.value.bar.baz]);

return (
<>
<div className=\\"test div\\">
{props.id}
{props.foo.bar.baz}
{props.foo.value.bar.baz}
</div>
<style jsx>{\`
.div {
Expand Down
28 changes: 16 additions & 12 deletions packages/core/src/__tests__/__snapshots__/solid.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -14086,25 +14086,27 @@ type Props = {

function MyBasicComponent(props: Props) {
const onUpdateFn_0_props_id = createMemo(() => props.id);
const onUpdateFn_0_props_foo_bar_baz = createMemo(() => props.foo.bar.baz);
const onUpdateFn_0_props_foo_value_bar_baz = createMemo(
() => props.foo.value.bar.baz
);
function onUpdateFn_0() {
console.log(\\"props.id changed\\", props.id);
console.log(\\"props.foo.value.bar.baz changed\\", props.foo.bar.baz);
console.log(\\"props.foo.value.bar.baz changed\\", props.foo.value.bar.baz);
}
createEffect(
on(
() => [onUpdateFn_0_props_id(), onUpdateFn_0_props_foo_bar_baz()],
() => [onUpdateFn_0_props_id(), onUpdateFn_0_props_foo_value_bar_baz()],
onUpdateFn_0
)
);

return (
<>
<div class=\\"test div-52492278\\">
<div class=\\"test div-70a61356\\">
{props.id}
{props.foo.bar.baz}
{props.foo.value.bar.baz}
</div>
<style>{\`.div-52492278 {
<style>{\`.div-70a61356 {
padding: 10px;
}\`}</style>
</>
Expand All @@ -14129,25 +14131,27 @@ type Props = {

function MyBasicComponent(props: Props) {
const onUpdateFn_0_props_id = createMemo(() => props.id);
const onUpdateFn_0_props_foo_bar_baz = createMemo(() => props.foo.bar.baz);
const onUpdateFn_0_props_foo_value_bar_baz = createMemo(
() => props.foo.value.bar.baz
);
function onUpdateFn_0() {
console.log(\\"props.id changed\\", props.id);
console.log(\\"props.foo.value.bar.baz changed\\", props.foo.bar.baz);
console.log(\\"props.foo.value.bar.baz changed\\", props.foo.value.bar.baz);
}
createEffect(
on(
() => [onUpdateFn_0_props_id(), onUpdateFn_0_props_foo_bar_baz()],
() => [onUpdateFn_0_props_id(), onUpdateFn_0_props_foo_value_bar_baz()],
onUpdateFn_0
)
);

return (
<>
<div class=\\"test div-52492278\\">
<div class=\\"test div-70a61356\\">
{props.id}
{props.foo.bar.baz}
{props.foo.value.bar.baz}
</div>
<style>{\`.div-52492278 {
<style>{\`.div-70a61356 {
padding: 10px;
}\`}</style>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7123,14 +7123,14 @@ export class MyBasicComponent {

componentDidUpdate() {
console.log(\\"props.id changed\\", this.id);
console.log(\\"props.foo.value.bar.baz changed\\", this.foo.bar.baz);
console.log(\\"props.foo.value.bar.baz changed\\", this.foo.value.bar.baz);
}

render() {
return (
<div class=\\"test div\\">
{this.id}
{this.foo.bar.baz}
{this.foo.value.bar.baz}
</div>
);
}
Expand Down
Loading