Last active
March 3, 2023 08:13
-
-
Save dyrkow/6162e36613c836848b484e1e797f5a90 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2. Решаем проблему с крашем всего приложения в пользу краша конкретной БОЛЬШОЙ части интерефейса, с возможностью исправить проблему вручную | |
<div> | |
<ErrorBoundary> | |
<ProfileScreen /> | |
</ErrorBoundary> | |
<ErrorBoundary title="Ошибка!" description="Что-то случилось" action={(props) => <Button onPress={props.onRefresh}>Повторить</Button>}> | |
<OrderItems /> | |
</ErrorBoundary> | |
<ErrorBoundary> | |
<OrderList /> | |
</ErrorBoundary> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4. Решаем проблему с фичами, теперь чтобы скрыть какую-то возможность лучше использовать HOC компонент | |
<Feature name="user.can.delete.sale_point" enabled> | |
<FeatureUserCanDeleteSalePoint /> | |
</Feature> | |
<Feature name="user.can.delete.sale_point" disabled> | |
<FeatureUserCanDeleteSalePoint /> | |
</Feature> | |
<Feature name="user.can.delete.sale_point" enabled andUserRoles={["admin", "director"]}> | |
<FeatureUserCanDeleteSalePoint /> | |
</Feature> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
type ForProps<TElement> = { | |
of: TElement[]; | |
render: (el: TElement, index: number) => JSX.Element; | |
} | |
/** | |
* Use for render array of data elements | |
* | |
* @example | |
* | |
* const NumberView = ({ item, index }) => <Text>{item}</Text>; | |
* | |
* <For<number> of={[1,2,3,4,5]} render={NumberView}> | |
*/ | |
export const For = <T,>({ of, render }: ForProps<T>): JSX.Element => <>{of.map(render)}</>; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
type IfProps = { | |
children: React.ReactElement<any>; | |
value: boolean; | |
otherwise?: JSX.Element; | |
} | |
/** | |
* Used for conditional rendering | |
* | |
* @example | |
* | |
* <If value={user.age > 18} otherwise={<BabyAlert messsage="You so baby"/>}> | |
* <Show18+ /> | |
* </If> | |
*/ | |
export const If = ({ value = true, children, otherwise = null}: IfProps): JSX.Element => value ? children : otherwise; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment