What is the best practice for structuring the state object in Redux in relation to related objects.
Example:
User has-one Organisation
With the above schema, where we also have a list of organisations is the following example a good idea?
{
user: {
id: 1,
organisation_id: 3,
first_name: 'Andrew',
last_name: 'McLagan',
email: '[email protected]',
organisation: {
name: 'Foo Bar Co.'
suburb: 'Booklyn',
phone: '123-123-000',
},
},
orgnaisations: [
{
id: 1,
name: 'Facebook'
suburb: 'Booklyn',
phone: '000-000-000',
},
{
id: 2,
name: 'Twitter'
suburb: 'Manhattan',
phone: '456-456-000',
},
{
id: 3,
name: 'Foo Bar Co.'
suburb: 'Booklyn',
phone: '123-123-000',
},
{
id: 4,
name: 'Some Org.'
suburb: 'Bronx',
phone: '642-642-000',
},
]
}
Or would it be better to access the users organisation by:
const organisation = state.organisations[user.organisation_id];