本文整理汇总了TypeScript中react-router.withRouter函数的典型用法代码示例。如果您正苦于以下问题:TypeScript withRouter函数的具体用法?TypeScript withRouter怎么用?TypeScript withRouter使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了withRouter函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: import
import('./components/ProfileContainer').then(i => callback(null, withRouter(i.default)));
示例2: createStructuredSelector
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { bindActionCreators } from 'redux';
import { createStructuredSelector } from 'reselect';
import { withRouter } from 'react-router';
import { connect, addRouting } from '../../helpers/migration';
import { App } from './app.component';
import { AuthActions, selectIsAuthenticated, selectActiveSession } from '../../modules/auth';
import { selectCurrentUser } from '../../modules/currentUser';
const mapStateToProps = createStructuredSelector({
isAuthenticated: selectIsAuthenticated,
hasActiveSession: selectActiveSession,
currentUser: selectCurrentUser
});
export const mapDispatchToProps = (dispatch) => bindActionCreators({
authenticate: AuthActions.authenticate,
logout: AuthActions.logout
}, dispatch);
export default addRouting(withRouter(connect(mapStateToProps, mapDispatchToProps)(App)));
示例3: createStructuredSelector
*/
import { connect } from '../../../helpers/migration';
import { bindActionCreators } from 'redux';
import { createStructuredSelector } from 'reselect';
import { Notifications } from './notifications.component';
import { NotificationsActions, selectNotifications, selectDrawerOpenState } from '../../../modules/notifications';
import { selectCurrentUser } from '../../../modules/currentUser';
import { withRouter } from 'react-router';
const mapStateToProps = createStructuredSelector({
notifications: selectNotifications,
currentUser: selectCurrentUser,
drawerOpened: selectDrawerOpenState
});
export const mapDispatchToProps = (dispatch) => bindActionCreators({
sendGetNotifications: NotificationsActions.sendGetNotifications,
sendUpdateNotificationRead: NotificationsActions.sendUpdateNotificationRead,
sendUpdateAllNotificationsRead: NotificationsActions.sendUpdateAllNotificationsRead,
sendDeleteNotification: NotificationsActions.sendDeleteNotification,
confirmSendDeleteAllNotifications: NotificationsActions.confirmSendDeleteAllNotifications,
upsertNotification: NotificationsActions.upsertNotification,
deleteNotification: NotificationsActions.deleteNotification,
showUpdatedFailedError: NotificationsActions.showUpdatedFailedError,
setDrawerPanelState: NotificationsActions.setDrawerPanelState
}, dispatch);
export default withRouter(connect(mapStateToProps, mapDispatchToProps)(Notifications));
示例4: createStructuredSelector
selectUsers,
selectCollaboratorLimit
} from '../../modules/userManagement';
import { selectJobs } from '../../modules/jobs';
import { TeamspacesActions } from '../../modules/teamspaces';
const mapStateToProps = createStructuredSelector({
usersSuggestions: selectUsersSuggestions,
users: selectUsers,
jobs: selectJobs,
limit: selectCollaboratorLimit
});
export const mapDispatchToProps = (dispatch) => bindActionCreators({
addUser: UserManagementActions.addUser,
removeUser: UserManagementActions.removeUser,
updateJob: UserManagementActions.updateJob,
updatePermissions: UserManagementActions.updatePermissions,
onUsersSearch: UserManagementActions.getUsersSuggestions,
clearUsersSuggestions: UserManagementActions.clearUsersSuggestions,
fetchQuotaInfo: TeamspacesActions.fetchQuotaInfo
}, dispatch);
export default withRouter(
connect(
mapStateToProps,
mapDispatchToProps
)(Users)
);
示例5: getPolls
return {
type: ownProps.type || queryParams.type || 'all',
status: ownProps.status || queryParams.status || 'all',
page: +queryParams.page || 1,
polls: getPolls(state),
totalRows: getTotal(state)
}
}
const mapDispatch = (dispatch: any, ownProps: any): MapDispatchProps => {
const queryParams: QueryParams = queryString.parse(ownProps.location.search)
const type = ownProps.type || queryParams.type || 'all'
const status = ownProps.status || queryParams.status || 'all'
return {
onPageChange: (page: number) =>
dispatch(navigateTo(locations.pollsTable(page, type, status))),
onStatusChange: (status: FilterStatus) =>
dispatch(navigateTo(locations.pollsTable(1, type, status))),
onFetchPolls: (pagination: PollsRequestFilters) =>
dispatch(fetchPollsRequest(pagination)),
onNavigate: (location: string) => dispatch(navigateTo(location))
}
}
export default withRouter(
connect(
mapState,
mapDispatch
)(PollsTable)
)