import {useContext} from 'react';

import {NewPostContext, NewPostContextType} from '../context/NewPostContext';

export const useNewPost = (): NewPostContextType => {
  const context = useContext(NewPostContext);
  if (!context) {
    throw new Error('useNewPost must be used within a NewPostProvider');
  }
  return context;
};
