import React, { useContext, useRef } from 'react'; import { TokenContext } from '../utilities/token-provider'; const NewsPublisher = props => { //context const authTokens = useContext(TokenContext); //refs const titleRef = useRef(); const authorRef = useRef(); const bodyRef = useRef(); return (

News Publisher

{ //on submit evt.preventDefault(); const [err, index] = await handleSubmit(titleRef.current.value, authorRef.current.value, bodyRef.current.value, authTokens.tokenFetch); if (err) { alert(err); } else { titleRef.current.value = authorRef.current.value = bodyRef.current.value = ''; alert(`Published as article index ${index}`); } }}>