Message from JavaScript discussions

October 2020

— Imagine it like:


const clickHandler = props.clickHandler || defaultClickHandler


(Props is a dynamic object which can be set at any time in react)

Message permanent page

— 

I see, so creating 2 components inside and initializing them isn't possible.. it's done by class extend, right

— Depends what u mean by initialize inside tho

— 

class Foo extends Component {
// ...
}
class Bar extends Component {
// ...
}


how to create 2 Bars inside Foo?

Message permanent page

— You don't create instances yourself, you render em

— React does the instance handling for u

— It'd be like

render() {
return (
<>
<Bar />
<Bar />
</>
)
}

Inside the foo class

— Like on rerenders it checks with some fiber magic which components need a rerender and updates the instances, if you do it wrong (or on purpose) you can also create new instances instead of updating the existing ones

Message permanent page

— Oke, so it's doable..

— Well ofc, but that's no subcomponent then, that's a child, guess naming conventions aren't equal everywhere :p

Message permanent page

— Ea

— There is a Modal library i can import it in react??