Created
October 10, 2018 15:10
-
-
Save navarroaxel/8186a94f08878f54c6ae195ed43806e9 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
// formThemeContext.js | |
const FormThemeContext = createContext({ | |
radio: {}, | |
textInput: {}, | |
integerInput: {} | |
}); | |
export default FormThemeContext; | |
const DwellingCharacteristics = () => ( | |
<FormThemeContext.Provider | |
value={ | |
textInput: { | |
color: 'blue' | |
}, | |
radio: { | |
container: { | |
backgroundColor: 'red' | |
} | |
} | |
} | |
> | |
<Section {...{chapter}}/> | |
</FormThemeContext.Provider> | |
) | |
// ..... Radio/index.js | |
import styles from './styles'; | |
const Radio = () => ( | |
<FormThemeContext.Consumer> | |
{({radio = {}}) => ( | |
<View | |
style={composeStyles(styles.container, radio.container)} | |
> | |
... | |
</View> | |
)} | |
</FormThemeContext.Consumer/> | |
) |
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
// formThemeContext.js | |
const defaultTheme = { | |
radio: {}, | |
textInput: {}, | |
integerInput: {} | |
}; | |
export createFormTheme = (theme) => ({...defaultTheme, ...theme}); | |
const FormThemeContext = createContext(defaultTheme); | |
export FormThemeContext; | |
const DwellingCharacteristics = () => ( | |
<FormThemeContext.Provider | |
value={createFormTheme( | |
textInput: { | |
color: 'blue' | |
}, | |
radio: { | |
container: { | |
backgroundColor: 'red' | |
}, | |
... | |
} | |
)} | |
> | |
<Section {...{chapter}}/> | |
</FormThemeContext.Provider> | |
) | |
// ..... Radio/index.js | |
import styles from './styles'; | |
const Radio = () => ( | |
<FormThemeContext.Consumer> | |
{({radio}}) => ( | |
<View | |
style={composeStyles(styles.container, radio.container)} | |
> | |
... | |
</View> | |
)} | |
</FormThemeContext.Consumer/> | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment