Skip to content

Commit

Permalink
fix Readme.md (callstack#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
anantadwi13 authored May 6, 2021
1 parent 525c4e2 commit e9bde3b
Showing 1 changed file with 11 additions and 24 deletions.
35 changes: 11 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,7 @@ class App extends React.Component {
export default withTheme(App);
```

You can also use the [hooks](https://reactjs.org/docs/hooks-intro.html) based API:

```js
function App() {
const theme = useTheme();

return <div style={{ color: theme.primaryColor }}>Hello</div>;
}
```

### Usage
Another usage for functional component:

```js
const App = ({ theme }) => (
Expand All @@ -92,6 +82,16 @@ const App = ({ theme }) => (
export withTheme(App);
```

You can also use the [hooks](https://reactjs.org/docs/hooks-intro.html) based API:

```js
function App() {
const theme = useTheme();

return <div style={{ color: theme.primaryColor }}>Hello</div>;
}
```

### Injected props

It will inject the following props to the component:
Expand Down Expand Up @@ -194,19 +194,6 @@ type WithThemeType<Theme> = React.ComponentType<{ theme: Theme }>

Higher Order Component which takes your component as an argument and injects `theme` prop into it.

## Applying a custom theme to a component

If you want to change the theme for a certain component, you can directly pass the theme prop to the component. The theme passed as the prop is merged with the theme from the Provider.

```js
import * as React from 'react';
import MyButton from './MyButton';

export default function ButtonExample() {
return <MyButton theme={{ roundness: 3 }}>Press me</MyButton>;
}
```

#### `useTheme`

**type:**
Expand Down

0 comments on commit e9bde3b

Please sign in to comment.