I am wondering if someone can help me out with this since I am new to react-native and redux.
I want to populate a FlatList with just a name and I am using this classes (along with others obviously):
actions.js
const LOAD_CLIENT = 'LOAD_CLIENT';
export async function loadClient() {
const client = await Parse.Query("Client");
return {
type: LOAD_CLIENT,
client: client,
};
}
reducers.js
import { LOAD_CLIENT } from '../actions'
const initialState = {
objectId: null,
name: null,
};
function client(state: State = initialState, action: Action): State {
if (action.type === LOAD_CLIENT) {
let {objectId, name} = action.client; // de-structuring action data
return {
objectId,
name,
};
}
return state;
}
module.exports = client;
listScreen.js
import {
loadClient
} from './actions'
class SettingsScreen extends Component {
render() {
return (
<View style={styles.container}>
<FlatList style={styles.listStyle}
data={this.props.client}
renderItem={({item}) => <Text>{item.name}</Text>}
/>
</View>
)
}
}
export default SettingsScreen
What do I need to be able to populate the list with client.name? I followed Redux basics to get here but now I am stuck.