import { createContext } from "react";
      
      export interface Tweet {
          id: string;
          content: string;
      }
      export interface TweetContext {
          tweets: Tweet[],
          setCurrTweets: (tweets: Tweet[]) => void;
      }
      const defaultContext: TweetContext = {
          tweets: [],
          setCurrTweets: () => { },
      };
      const TweeterContext = createContext<TweetContext>(defaultContext);
      export default TweeterContext;
      
      Typescript language logo

      react context hook

      React Native Recipes

      if you need a way to update a custom context through a hook, this recipe will generate an example of how to write such a hook.

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.