Flowseal / TravelPractice

0 stars 0 forks source link

lesson-8: Много параметров прокидывается вниз по дереву компонентов #14

Open LehaIvanov opened 1 year ago

LehaIvanov commented 1 year ago

https://github.com/Flowseal/TravelPractice/blob/8e8d193b2c2ee52de62bb03317dd298d916e160b/Lesson8%20(Currency%20Converter)/WebAppUI/src/components/ConvertationForm/ConverationForm.tsx#L16

type ConvertationFormProps = {
    currencies: Currency[];
    price: number;
    paymentAmount: string;
    paymentCurrency: string;
    purchasedCurrency: string;
    onCurrencyChange: (paymentCurrency: string, purchasedCurrency: string, swapped: boolean) => void;
    onPaymentAmountChange: (paymentAmount: string) => void;
};

Если добавиться ещё вложенность то совсем тяжело будет все эти параметры через пропсы переадвать. Почему-бы не использовать Context?