Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

destructring global state at one place

const {
    bookings,
    isLoading,
    isUpdating,
    isLoaded,
    companies,
    isCompaniesLoaded,
    isCompaniesLoading,
    selectedCompany,
    selectedResource,
    isWeekView,
    startDate,
    endDate,
    showCancelledBookings,
    hideBufferTime,
  } = useSelector(state => ({
    bookings: state.booking.bookings,
    isLoading: state.booking.isLoading,
    isLoaded: state.booking.isLoaded,
    isUpdating: state.booking.isUpdating,

    companies: state.company.companies,
    isCompaniesLoaded: state.company.isLoaded,
    isCompaniesLoading: state.company.isLoading,

    selectedCompany: state.company.selectedCompany,
    selectedResource: state.company.selectedResource,
    isWeekView: state.booking.additionalParams.isWeekView,

    startDate: state.booking.additionalParams.startDate,
    endDate: state.booking.additionalParams.endDate,

    showCancelledBookings: state.booking.additionalParams.showCancelledBookings,
    hideBufferTime: state.booking.additionalParams.hideBufferTime,
  }), shallowEqual);
 
PREVIOUS NEXT
Tagged: #destructring #global #state #place
ADD COMMENT
Topic
Name
3+8 =