Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6364

My app wasn't able to rerender on installation startup 'singleton' that I have created ONLY when I generate the apk file through eam build

$
0
0

My app wasn't able to rerender on installation startup 'singleton' that I have created ONLY when I generate the apk file through eam build.

It is working when I use expo-go I have click on one of the other button (this case, my own create exercise button) for it to force rerender again. this create button sets a useState to render a 'Modal'

I am really tired of working on this. Hope there is some suggestions for this bug.

export default function App() {  const [exerciseState, setExerciseState] = useState<ExerciseState>(initialExerciseState)  const [scheduledItemState, setScheduledItemState] =    useState<ScheduledItemState>(initialScheduledItemState)  const [dialogState, SetDialogState] = useState<DialogState>(initialDialogState)  const [emm, setEmm] = useState(initialEmm)  useEffect(() => {    let tempExercises: Exercise[]    if (exerciseState.exercises[0] != undefined)      if (exerciseState.exercises[0].name == ""        || exerciseState.exercises.length <= 0)        retrieveExercises((_, r) => {          tempExercises = r.rows._array          tempExercises.forEach(ex => ex.major_muscles = initialMajorMuscles)          setExerciseState({            ...exerciseState, exercises: tempExercises,            filteredExercises: tempExercises          })        })    if (scheduledItemState.scheduledItems[0] != undefined&& exerciseState.exercises[0] != undefined)      if (scheduledItemState.scheduledItems[0].exercise == initialExerciseState.aExercise&& exerciseState.exercises[0] != initialExerciseState.exercises[0])        retrieveScheduledItems(          (_, results) => {            const tempScheduledItems: ScheduledItem[] = results.rows._array            const a = results.rows._array.slice()            tempScheduledItems.forEach((ms, index) => {              ms.date = JSON.parse(ms.date.toString())              const t = exerciseState.exercises.find(ex => ex.name == a[index].exercise)              tempScheduledItems[index].exercise = t!            })            setScheduledItemState({              ...scheduledItemState, scheduledItems: tempScheduledItems, filteredScheduledItems: tempScheduledItems            })          })    if (exerciseState.majorMuscles[0] == initialMajorMuscles[0]) {      retrieveMajorMuscles(        (_, results) => setExerciseState({          ...exerciseState,          majorMuscles: results.rows._array        }))    }    if (emm[0] == initialEmm[0])      retrieveExerciseMajorMuscleRelationships(        (_, results) => setEmm(results.rows._array))    if (exerciseState.majorMuscles[0] != initialMajorMuscles[0]&& exerciseState.exercises[0] != initialExerciseState.exercises[0]&& emm[0] != initialEmm[0]) {      emm.forEach(x => {        const ex: Exercise =          exerciseState.exercises.find(e => e.name == x.exercise_name)!        const mm2: MajorMuscle = exerciseState          .majorMuscles          .find(mm => mm.name == x.major_muscle_name)!        if (ex == undefined || mm2 == undefined) return        if (ex.major_muscles == initialMajorMuscles)          ex.major_muscles = [mm2!]        else if (!ex.major_muscles.find(x => x.name == mm2.name))          ex.major_muscles.push(mm2!)      })    }  }, [scheduledItemState, exerciseState, emm]).....

Viewing all articles
Browse latest Browse all 6364

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>