Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

Modify Interface values while using useContext in React Native

$
0
0

I have a context like this,In each page I have to update certain fields in the interface from their initial values,how can I change each values in that interface

Assignment operator shows error :- The left-hand side of an assignment expression may not be an optional property access.ts(2779)

import * as React from "react";interface OrderContextInterface {    outboundQuoteId: string;    senderId: string;    receiverId: string;    routeId: number;    paymentOptionId: number;    purposeOfTransaction: string}export const OrderContext = React.createContext<OrderContextInterface | null>(null);export const initialOrder: OrderContextInterface = {    outboundQuoteId: '',    senderId: '',    receiverId: '',    routeId: 0,    paymentOptionId: 0,    purposeOfTransaction: '',};//In Other Screens  useEffect(() => {    order?.outboundQuoteId="ada";     **//error** }, []);//contextsconst order = useContext(OrderContext);

Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>