TodoItem component type checking for optional prop I have a TodoItem component that looks like this:
type Todo = {
  id: string;
  text: string;
  isCompleted: boolean;
  createdAt: string;
};

type TodoProps = {
  todo: Todo;
  removeTodo: (id: string) =&gt; void;
  markCompletedTodo?: (id: string) =&gt; void;
};

const TodoItem = ({ todo, removeTodo, markCompletedTodo }: TodoProps) =&gt; {
  return (
    &lt;div&gt;
      &lt;h2&gt;{todo.text}&lt;/h2&gt;
      &lt;button type=&quot;button&quot; onClick={() =&gt; removeTodo(todo.id)}&gt;
        Remove
      &lt;/button&gt;
      {typeof markCompletedTodo === 'undefined' ? null : (
        &lt;button type=&quot;button&quot; onClick={() =&gt; markCompletedTodo(todo.id)}&gt;
          Mark completed
        &lt;/button&gt;
      )}
    &lt;/div&gt;
  );
};

export default TodoItem;

As you can see, it gets a todo with a isCompleted property. I want to render the 'Mark completed' button only is the isCompleted property is false, but currently I'm checking for the optional markCompletedTodo prop. That works but I have the feeling this can be done in a better way.
I'm using it to create two lists of TODOS, one for incomplete TODOS and one for complete TODOS, so I'm using it like this in another component:
return (
  &lt;h2&gt;Incomplete TODOS&lt;/h2&gt;
  {incompleteTodos.map((todo) =&gt; (
    &lt;TodoItem
    key={todo.text}
    todo={todo}
    removeTodo={removeTodoRequest}
    markCompletedTodo={markCompletedTodoRequest}
    /&gt;
  ))}
  &lt;h2&gt;Complete TODOS&lt;/h2&gt;
  {completeTodos.map((todo) =&gt; (
    &lt;TodoItem
      key={todo.text}
      todo={todo}
      removeTodo={removeTodoRequest}
    /&gt;
  ))}
)

Is there a better approach to this regarding the type checking and the prop types in the TodoItem component, or any other aspect?
Make the shapes the same In my experience, TypeScript is easiest when similar data has the same shape (type). Rather than conditionally passing a markCompletedTodo, consider passing that prop unconditionally, and in the child component, check todo.isCompleted when you need to identify whether to add the button or not.
Duplicate key bug You use:
{incompleteTodos.map((todo) =&gt; (
  &lt;TodoItem
  key={todo.text}

What if the todo text is the same? Maybe someone adds &quot;Get groceries&quot; Tuesday, then comes back to the app on Thursday and adds &quot;Get groceries&quot; again for the next week. This means that you'll have duplicate mapped keys, which should not be done and will confuse React, possibly creating rendering problems.
Since it looks like todos have IDs, use those IDs as keys instead.
&amp;&amp; instead of conditional To conditionally render in React, you can use &amp;&amp; or || to test, and put the element to be rendered on the right-hand side - it's a bit more concise than the conditional operator.
You could do something like:
// You could rename the definition of removeTodoRequest to removeTodo
// and markCompletedTodoRequest to markCompletedTodo
// so that you can use shorthand property names below:
const makeTodoItem = (todo: Todo) =&gt; (
  &lt;TodoItem
    key={todo.id}
    {...{ todo, removeTodo, markCompletedTodo }}
  /&gt;
);
return (
  &lt;h2&gt;Incomplete TODOS&lt;/h2&gt;
  {incompleteTodos.map(makeTodoItem)}
  &lt;h2&gt;Complete TODOS&lt;/h2&gt;
  {completeTodos.map(makeTodoItem)}
); // don't forget this semicolon

type TodoProps = {
  todo: Todo;
  removeTodo: (id: string) =&gt; void;
  markCompletedTodo: (id: string) =&gt; void;
};

const TodoItem = ({ todo, removeTodo, markCompletedTodo }: TodoProps) =&gt; {
  return (
    &lt;div&gt;
      &lt;h2&gt;{todo.text}&lt;/h2&gt;
      &lt;button type=&quot;button&quot; onClick={() =&gt; removeTodo(todo.id)}&gt;
        Remove
      &lt;/button&gt;
      {!todo.isCompleted &amp;&amp; (
        &lt;button type=&quot;button&quot; onClick={() =&gt; markCompletedTodo(todo.id)}&gt;
          Mark completed
        &lt;/button&gt;
      )}
    &lt;/div&gt;
  );
};