'how to activate all the starts of my stopwatch

I'm looking for a way to activate all my timers by pressing only the start button on the main timer sorry for the quality of the picture enter image description here my main timer and my small timer are in two different folders

and in this two timers it has exactly the same functions it has that the style that changes here is the code

import React, { Component } from "react";
import { StyleSheet, View, TouchableHighlight, Image } from "react-native";
import { startService } from "../_services";

//Screen

import Timer from "./Timer";
import ButtonsRow from "./ButtonsRow";
import RoundButton from "./RoundButton";

export default class App extends Component {
    constructor(props) { 
      super(props); 
      this.state = { start: 0, now: 0, laps: [], }; } 

    componentWillUnmount() { clearInterval(this.timer); }

    start = () => { 
         const now = new Date().getTime(); 
         this.setState({ start: now, now, laps: [0], }); 
         this.timer = setInterval(() => { 
              this.setState({ now: new Date().getTime() }); }, 100);                           startService.sendstart("Go"); };

    lap = () => { 
        const timestamp = new Date().getTime(); 
        const { laps, now, start } = this.state; 
        const [firstLap, ...other] = laps; this.setState({ laps: [0, firstLap + now - start, ...other], start: timestamp, now: timestamp, }); };

    stop = () => { 
         clearInterval(this.timer); 
         const { laps, now, start } = this.state; 
         const [firstLap, ...other] = laps; 
         this.setState({ laps: [firstLap + now - start, ...other], 
         start: 0, now: 0, }); startService.clearstart(); }; 
         reset = () => { this.setState({ laps: [], start: 0, now: 0, }); }; 

   resume = () => { 
          const now = new Date().getTime(); 
          this.setState({ start: now, now, }); 
          this.timer = setInterval(() => { 
                       this.setState({ now: new Date().getTime() }); }, 100); }; 

   render() { const { now, start, laps, startTotal } = this.state; const timer = now - start;
    return ( <View style={styles.container}> 
               <Timer interval={laps.reduce((total, curr) =>  total + curr, 0) + timer} />              
                 {laps.length === 0 && ( 
                     <ButtonsRow> 
                        <RoundButton title="TOUR" color="#FFF"  background="#151515" />                
                        <RoundButton
                         title="Start"
                         color="#FFF"
                         background="#FB7445"
                         onPress={this.start}
            /> </ButtonsRow> )} 
             {start > 0 && ( <ButtonsRow> 
             <RoundButton
              title="TOUR"
              color="#FFF"
              background="#FB7445"
              onPress={this.lap}
            /> <RoundButton
              title="Stop"
              color="#FFF"
              background="#3C1715"
              onPress={this.stop}
            /> </ButtonsRow> )} 
           {laps.length > 0 && start === 0 && ( 
             <ButtonsRow> 
               <TouchableHighlight onPress={this.reset}> 
                 <Image source={require("../../assets/images/rezet.png")} style=                  {styles.logo_rezet} /> 
               </TouchableHighlight> 
            <RoundButton
              title="restart"
              color="#FFF"
              background="#d40b0e"
              onPress={this.resume}
            /> </ButtonsRow> )} </View> ); } }

const styles = StyleSheet.create({ container: { flex: 1, paddingTop: 10, }, logo_rezet: { height: 40, width: 40, marginTop: 170, marginLeft: 160, }, });

I tried to put my start function in another folder but it doesn't work I also tried with a subject I also tried to put some back and have it check the back value but nothing works



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source