Skip to content

Commit

Permalink
docs: update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mym0404 committed Jun 14, 2024
1 parent 63acffb commit a1db2f3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions doc/docs/example-components/styled-image.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ sidebar_position: 4

# StyledImage

:::tip
We recommand use `createSxComponent` to `Image` of React Native.
:::

```tsx title='StyledImage.tsx'
import type { PropsWithChildren, Ref } from 'react';
import React, { forwardRef } from 'react';
Expand Down
4 changes: 4 additions & 0 deletions doc/docs/example-components/styled-view.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ sidebar_position: 1
title: StyledView
---

:::tip
We recommand use `createSxComponent` to `View` of React Native.
:::

```tsx title='StyledView.tsx'
import { forwardRef, Ref, PropsWithChildren } from 'react';
import { View, ViewProps } from 'react-native';
Expand Down
18 changes: 18 additions & 0 deletions doc/docs/usage/component.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,24 @@ How to use the completed `StyledView` component is as follows.

It can be defined as follows:


### Method 1 - use `createSxComponent` HOC

```tsx title="StyledView.tsx"
import type { ComponentProps } from 'react';
import { View } from 'react-native';
import { createSxComponent } from '@react-native-styled-system/core';

export const StyledView = createSxComponent(View)();
export type StyledViewProps = ComponentProps<typeof StyledView>;
```

`createSxComponent` and `createSxTextComponent` are simple but may have limitations in their usage.

These HOCs simply add style-related fields to the Props and create a style object to pass to the passed view.

### Method 2 - use `useSx` hook manually

```tsx title="StyledView.tsx"
import { forwardRef, Ref, PropsWithChildren } from 'react';
import { View, ViewProps } from 'react-native';
Expand Down

0 comments on commit a1db2f3

Please sign in to comment.