-
Notifications
You must be signed in to change notification settings - Fork 6
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
Why model
prop is passed to original view component?
#8
Comments
It is useful in cases where you don't have children components but you want to create reusable feature. Created view has "model" field in it's props signature. Reading types is better than expecting. |
99% of components in our projects use model directly from props |
This means that you need to add type of model in component props in 99% cases? |
I think it's kinda cheap type Props = {
model: Model<typeof myCoolModelFactory>
otherProp: unknown
}
const MyCoolView = modelView(myCoolModelFactory, ({model, otherProp}: Props) =>{
return null;
}) Is you haven't any extra props, so better const MyCoolView = modelView(myCoolModelFactory, ({model}) =>{
return null;
}) |
Hi. Why
model
prop is passed to original view component?This is needed only for types?
Because I wasn't expected to receive it alongside with my component props.
const FeatureComponentSelect = modelView(factory, (props: SelectProps) => { const model = factory.useModel(); // some code inside return <Select {...props} /> })
So in the DOM I have
model
prop passed.So this is a problem, and I need somehow to make 2 steps to solve this issue
props: SelectProps & { model: ReturnType<typeof factory.useModel> }
model
prop from itSo, my question is - why you pass
model
prop to original component if you never use it (model
is always is extracted throughfactory.useModel
hook)My suggestion is to separate viewProps from model like this
The text was updated successfully, but these errors were encountered: