Нужно вывести кол-во выбранных(число) checkbox'ов в кнопку

function commonCollectOrderDesktop(collect_order: ViewModel.CollectOrder, state: State, index: number) {
  return (<tr key={index}>
    <td><input type='checkbox' className='check'/></td>//эти чекбоксы
    <td>{collect_order.id}</td>
    <td>{getObjectByIdAndName(collect_order.warehouse_id, state.array_of_warehouse)}</td>
    <td>{getObjectByIdAndName(collect_order.legal_entity_id, state.array_of_legal_entity)}</td>
    <td>{collect_order.creation_date_time}</td>
    <td>{collect_order.count_of_product}</td>
  </tr>);
}

Нужно вывести в эту кнопку-
 {state.array_of_collect_order.length > 0
      ? (<button onClick={(event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
        event.preventDefault();
        console.log(state.array_of_collect_order)
        for (let i of state.array_of_collect_order) {
          console.log(i["id"])//тест
        }
      }}>Собрать&nbsp;
        {state.array_of_collect_order.length}&nbsp;    
        {defineTitle((state.array_of_collect_order.length), "заказ", "заказа", "заказов")}
      </button>)
      : null
    }

Ответы (0 шт):