I have the start of s simple todo app in with React and typescript
I am creating a context but getting an error in the value of the content provider
<TodoContext.Provider value={contextValue}>{children}</TodoContext.Provider>
for the value I get the error
Type '{ todoList: string[]; }' is not assignable to type 'null'.
What does error mean and how can i fix this typescript error
import { createContext, useContext, useState, ReactChildren, ReactChild } from "react";
interface AuxProps {
children: ReactChild | ReactChildren;
}
const TodoContext = createContext(null)
const intialTodo = ['Learn Context']
const TodoProvider = ({children}:AuxProps) => {
const [todoList, setTodoList] = useState<string[]>(intialTodo)
const contextValue = {
todoList
}
return(
<TodoContext.Provider value={contextValue}>{children}</TodoContext.Provider>
)
}
export const useTodoContext = () => useContext(TodoContext)
export default TodoProvider