Message from JavaScript discussions

October 2020

— It's implementation question.. can you override default y logic or not

— 

Subcomponents is rather a component structure thing, they're still 2 individual independent componentes

— In react*

Fu train tunnel, rip the net

— As I said, depends on your design
You can pass whatever u want, it's still just a props thing in react 🤷🏿‍♂️

Message permanent page

— 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

Message permanent page

— 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