Passing data between components using Formik

Hello, Im following the react native course and I have a problem with passing data between two components.

This is short sample of my code:

First component (to enter data):

import React from "react";
import { Formik } from "formik";
import { View, Button, TextInput } from "react-native";

function MyForm({ tasks, setTasks }) {
  return (
        initialValues={{ task: "" }}
        onSubmit={(values) => setTasks(values)}
        {({ handleChange, handleSubmit }) => (
              placeholder="Write a task"

            <Button onPress={setTasks} title="Click" />

export default MyForm;

Second component (to display data):

import React from "react";
import { View, Text } from "react-native";
import MyForm from "./MyForm";

const TaskContainer = ({ tasks, setTasks }) => {
  return (
      <Text>Here is the list:</Text>
      { => (

export default TaskContainer;

Im trying to pass the data between both components and display it in second component.
This is sample, what I want to see:


I will be grateful for any advice how to do it correctly.