Is it possible to define a custom saga for the List component? I mean, when the List is mounted it dispatch the action RA/CRUD_GET_LIST
that automatically (due to props passed down from parent components), fetches the data from the server. I want to define my own RA/CRUD_GET_LIST
with different behaviour, is it possible?
List component:
<List
{...this.sanitizeProps(this.props)}
filter={{ userId: userId }}
title="History"
perPage={10}
>
<DataGridComponent />
</List>
With sanitizeProps
I filter the props that I need and pass down the others.
The resource I need to wait for is: <Resource name="user" />
I'm getting the userId
from my custom reducer:
const mapStateToProps = state => ({
userId: state.userReducer.user.id
});
To answer your question, no, it's not possible. However, you can achieve the result you want by wraping your List inside a connected component and only it render the List
when you have a user_id. Otherwise, just return null or something indicating you're loading stuff.
const MyConnectedList = ({ userId, ...props }) =>
userId
? (
<List
{...this.props}
filter={{ userId }}
title="History"
perPage={10}
>
<DataGridComponent />
</List>
)
: null