Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

nextjs update ui when data is updated

JS
import { useRouter } from 'next/router';
function SomePage(props) {
  const router = useRouter();
  // Call this function whenever you want to
  // refresh props!
  const refreshData = () => {
    router.replace(router.asPath);
  }
}
export async function getServerSideProps(context) {
  // Database logic here
}
Source by www.joshwcomeau.com #
 
PREVIOUS NEXT
Tagged: #nextjs #update #ui #data #updated
ADD COMMENT
Topic
Name
2+9 =