is manually setting props of a component returned by a render prop considered bad practice?
let's say i have this component:
if i were to set one of
rendered
's props before returning from Foo
like this:
would that be considered bad practice?Solution:Jump to solution
```tsx
function Foo(props: {renderSomething: (param: any) => VNode}) {
const rendered = props.renderSomething("hi theo");
const derivedSomething = useMemo(() => {
return {...rendered, someProp: 2}...
6 Replies
yes and no
why after calling
renderSomething
you would need to change the result manually
but should work regardlesstwo words: bad architecture
derive it
mutating a prop is bad bad bad
now that i think of it, i should use a context instead of "injecting" props posthumously
use a useMemo
Solution