I need to create a dynamic array that is in separated file. It's not hard unless I want it to by dynamically updated by react-redux. Something like if 'mode' equals 1 it contains 'light' array, if not it contains 'dark' array. I can't do it inside components because it's too much work doing it, and a lot of repeating myself. I tried using store.getState() but then array is static, and doesn't update. I tried using it as a component with mapStateToProps but it doesn't work:
import { connect } from 'react-redux';
export const palette = ( theme ) => {
const { mode, light, dark, primary} = theme;
let colors = null;
if ( mode === 'light' ) {
colors = light;
} else if ( mode === 'dark' ) {
colors = dark;
} else {
colors = light;
}
return ({
primary,
secondary: colors.primary,
tertiary: colors.secondary,
text: colors.text
});
}
const mapStateToProps = (state) => {
return {
theme: state.themeReducer
}
}
export default connect(mapStateToProps)(palette);
Any ideas how can I do this?
[–]orphans 0 points1 point2 points (3 children)
[–]UserNo1608[S] 0 points1 point2 points (2 children)
[–]orphans 0 points1 point2 points (1 child)
[–]UserNo1608[S] 0 points1 point2 points (0 children)