Skip to content
This repository was archived by the owner on Aug 23, 2022. It is now read-only.

Commit 62af223

Browse files
committed
Remove Control.Custom and update docs with correct approach for custom components
1 parent 4cdcd88 commit 62af223

File tree

2 files changed

+9
-51
lines changed

2 files changed

+9
-51
lines changed

docs/guides/react-native.md

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -111,37 +111,23 @@ export default Form;
111111
```
112112

113113
## Using Custom Form Components
114-
If you are using a third-party form control component that delegates to a standard React Native iOS form control, you can use `Control.Custom` and provide a `delegate` prop. The `component` prop in this case is the custom component you're using.
115-
116-
The supported controls are:
117-
118-
* 'MapView'
119-
* 'Picker'
120-
* 'Switch'
121-
* 'TextInput'
122-
* 'DatePickerIOS'
123-
* 'SegmentedControlIOS'
124-
* 'Slider'
125-
126-
Any custom form control can be used so long as it ultimately resolves to one of these React Native controls.
114+
To use a third-party form control component select the appropriate `Control` type (e.g., `Control.TextInput`) and override the `component` prop with your custom component. The custom component must resolve to one of the supported React Native form control types. See the supported types [here](#native-controls).
127115

128116
```jsx
129117
import React from 'react-native';
130118
import { Form, Control } from 'react-redux-form/native';
131-
import { Input, Item } from 'native-base';
119+
import { Input } from 'native-base';
132120

133121
class Form extends React.Component {
134122
render() {
135123
return (
136-
<Form model="user">
137-
<Item regular>
138-
<Control.Custom
139-
placeholder="Last Name"
140-
model=".last_name"
141-
component={Input}
142-
delegate="TextInput"
143-
/>
144-
</Item>
124+
<Form model="user">
125+
<Control.TextInput
126+
placeholder="Last Name"
127+
model=".last_name"
128+
component={Input}
129+
delegate="TextInput"
130+
/>
145131
</Form>
146132
);
147133
}

src/native.js

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -149,34 +149,6 @@ Control.Slider = (props) => (
149149
/>
150150
);
151151

152-
Control.Custom = (props) => {
153-
const delegates = [
154-
'MapView',
155-
'Picker',
156-
'Switch',
157-
'TextInput',
158-
'DatePickerIOS',
159-
'SegmentedControlIOS',
160-
'Slider',
161-
];
162-
163-
if (! props.delegate || ! delegates.includes(props.delegate)) {
164-
throw new Error(`Delegate not found. Must be one of: [${delegates.map(d => `'${d}'`)}]`);
165-
}
166-
const CustomComponent = Control[props.delegate];
167-
168-
return (
169-
<CustomComponent
170-
component={props.component}
171-
{...omit(props, 'mapProps')}
172-
/>
173-
);
174-
};
175-
176-
Control.Custom.propTypes = {
177-
delegate: PropTypes.string.isRequired,
178-
};
179-
180152
const NativeForm = (props) => <Form component={View} {...omit(props, 'mapProps')} />;
181153
const NativeFieldset = (props) => <Fieldset component={View} {...omit(props, 'mapProps')} />;
182154
const NativeErrors = (props) => (

0 commit comments

Comments
 (0)