Versions
Material-UI: 0.18.0
React: 15.5.4
Redux: 3.6.0
Browser: Chrome -- Version 59.0.3071.115 (Official Build) (64-bit)
Problem
I am using redux for application wide state management instead of setState. When calling redux actions the checkbox doesn't register as checked, but it registers that it was clicked when I console.log the onRowSelection. If I remove the line calling my action, the checkboxes work just fine. For some reason, Material UI is blocked from updating when I call my redux action.
--Edit--
It appears that it's not the action that is causing the malfunction it's something about my reducer that material UI's Table doesn't like.
(added reducer snippet below)
Table Component
class AdminDeptAppAccess extends React.Component {
_onRowSelection (selectedUsers, props) {
console.log(selectedUsers)
props.selectedUsersAction(filterUsers(selectedUsers, props.deptAppRoles))
}
render () {
return (
<Table
selectable
multiSelectable
onRowSelection={(selectedUsers) => this._onRowSelection(selectedUsers, this.props)}
>
{/* contents */}
</Table>
)
}
}
const filterUsers = (selectedUsers, deptAppRoles) => {
if (selectedUsers === 'all') {
return deptAppRoles
} else if (selectedUsers === 'none') {
return []
} else if (selectedUsers === []) {
return []
} else {
let users = []
selectedUsers.map((num, i) => (
users.push(deptAppRoles[num])
))
return users
}
}
applicable redux action that was passed down via props
export const selectedUsersAction = (users) => {
console.log('selectedUsersAction', users)
return dispatch => {
dispatch({
type: 'SELECTED_USERS',
selectedUsers: users
})
}
}
applicable reducer
const admin = (state = { selectedUsers: [] }, action) => {
switch (action.type) {
// ...
case 'SELECTED_USERS':
return Object.assign({}, state, {
selectedUsers: action.selectedUsers
})
default:
return state
}
}
screenshot
ignore the console errors, they are from something else.
I selected the first row, and the console registers that [0] was clicked, and my redux action registers who got clicked, but the checkbox doesn't update because my redux action (reducer) somehow blocked the component from rendering the updated checkbox.
