Closed yuri-htt closed 6 years ago
When I tried it, no error occurred, but no data came to props.
I did the following. ・Change Provider to what is provided from react-redux ・Pass store to Provider
I thought that it was not necessary to do particularly difficult things, but is it necessary to do something?
import * as React from 'react'; import { Dimensions } from 'react-native'; import { Provider } from 'react-redux'; import configureStore from '../redux/configureStoreForWeb'; import loadTranslations from '../i18n/translations'; const store = configureStore(); const { Consumer } = React.createContext({ width: 0, height: 0 }); loadTranslations(); class DimensionsProvider extends React.Component { constructor(props) { super(props); this.state = this.getDimensions(); } getDimensions() { const { width, height } = Dimensions.get('window'); return { width, height }; } updateDimensions = () => { this.setState(this.getDimensions()); }; componentDidMount() { Dimensions.addEventListener('change', this.updateDimensions); } componentWillUnmount() { Dimensions.removeEventListener('change', this.updateDimensions); } render() { const { children } = this.props; return ( <Provider value={this.state} store={store}> {children} </Provider>); } } export default { Provider: DimensionsProvider, Consumer };
I was able to implement Redux's incorporation!
When I tried it, no error occurred, but no data came to props.
I did the following. ・Change Provider to what is provided from react-redux ・Pass store to Provider
I thought that it was not necessary to do particularly difficult things, but is it necessary to do something?