Skip to content

Commit 959582e

Browse files
committed
docs: add section about customizing components
1 parent 29f21bc commit 959582e

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

docs/pages/1.getting-started.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ If you have another provider (such as `Redux`), wrap it outside `PaperProvider`
5656
```js
5757
import * as React from 'react';
5858
import { Provider as PaperProvider } from 'react-native-paper';
59-
import { Provider as StoreProvider } from 'redux';
59+
import { Provider as StoreProvider } from 'react-redux';
6060
import App from './src/App';
6161
import store from './store';
6262

docs/pages/2.theming.md

+17
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,23 @@ export default withTheme(MyComponent);
103103

104104
Components wrapped with `withTheme` support the theme from the `Provider` as well as from the `theme` prop.
105105

106+
## Customizing all instances of a component
107+
108+
Sometimes you want to style a component in a different way everywhere and don't want to change the properties in the theme so that other components are not affected. For example, say you want to change the font of all your buttons, but don't want to change `theme.fonts.medium` because it affects other components.
109+
110+
We don't have an API to do this, because you can already do it with components:
111+
112+
```js
113+
import * as React from 'react';
114+
import { Button } from 'react-native-paper';
115+
116+
export default function RoundButton(props) {
117+
return <Button theme={{ fonts: { medium: 'Open Sans' } }} {...props} />;
118+
}
119+
```
120+
121+
Now you can use `RoundButton` everywhere instead of using `Button`.
122+
106123
## Gotchas
107124

108125
The `Provider` exposes the theme to the components via [React's context API](https://reactjs.org/docs/context.html), which means that the component must be in the same tree as the `Provider`. Some React Native components will render a different tree such as a `Modal`, in which case the components inside the `Modal` won't be able to access the theme. The work around is to get the theme using the `withTheme` HOC and pass it down to the components as props, or expose it again with the exported `ThemeProvider` component.

src/components/BottomNavigation.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ type Props<T> = {
4848
*
4949
* Each route object should contain the following properties:
5050
*
51-
* - `key`: a unique key to identify the route
51+
* - `key`: a unique key to identify the route (required)
5252
* - `title`: title of the route to use as the tab label
5353
* - `icon`: icon to use as the tab icon, can be a string, an image source or a react component
5454
* - `color`: color to use as background color for shifting bottom navigation
@@ -207,6 +207,8 @@ const INACTIVE_LABEL_SIZE = 12;
207207
* Bottom navigation provides quick navigation between top-level views of an app with a bottom tab bar.
208208
* It is primarily designed for use on mobile.
209209
*
210+
* For integration with React Navigation, you can use [react-navigation-tabs](https://github.com/react-navigation/react-navigation-tabs).
211+
*
210212
* <div class="screenshots">
211213
* <img class="medium" src="screenshots/bottom-navigation.gif" />
212214
* </div>

0 commit comments

Comments
 (0)