Skip to content
  • 619-209 467 8400
  • 2096 Dennison Street, Stockton, CA – 95202
Main Demo
  • Categories 
    • Marketing 
      • All Marketing
      • Amazon FBA
      • Instagram Marketing
      • Digital Marketing
      • Google Analytics
      • Project Management
      • Product Manager
    • Development 
      • All Development
      • JavaScript
      • Angular 8
    • IT & Software 
      • All IT & Software
      • Cyber Security
      • AWS
      • Web Developer
      • Copywriting
    • Business
    • Design 
      • All Design
      • Graphic Design
      • Character Art
      • Adobe XD
      • Filmmaker Guide
    • Photography 
      • All Photography
      • Architecture Photography
      • Cinematography
Search for:
  • Home
  • Courses 
    • Recent Courses

      SEE ALL COURSES >

      Course Layouts
      rich-img

      Course Default

      The classic course layout for those who like it minimalistic

      rich-img

      Course Classic

      Show your courses in classic style with Elementor page builder

      rich-img

      Course List Style

      Organize every course in List order with list layout of the theme

      rich-img

      Course Categories

      Show a single course with Single category layout style crafted with Elementor

  • Pages 
    • rich-img

      About Us

      Know about our business history and our team

      rich-img

      Careers

      Take the next step of your career journey with us

      rich-img

      Become a Teacher

      Train the next generation of tech students

      rich-img

      Success Stories

      Our students success, our pride

      rich-img

      Help Center

      Free resources & support to grow your business

      rich-img

      FAQ

      Free resources to help you grow your business

    • About Us
    • Become a Teacher
    • Careers
    • Help Center
    • FAQ
  • Blog 
    • Latest post

      June 3, 2020

      Make The Leap To Digital Illustration: 7 Drawing Apps
      Read more
      Manager content hub
      rich-img

      Blog Articles

      Smart and simple advice and tools to help you be a better leader for your team

      rich-img

      Grid Style

      Articles and our latest thinking on onboarding, employee experience and more

      rich-img

      Blog Masonry

      Articles and our latest thinking on onboarding, employee experience and more

    • Blog List
    • Blog Grid
  • Contact
Main Demo
Menu Close
  • Home
  • Courses 
    • Recent Courses

      SEE ALL COURSES >

      Course Layouts
      rich-img

      Course Default

      The classic course layout for those who like it minimalistic

      rich-img

      Course Classic

      Show your courses in classic style with Elementor page builder

      rich-img

      Course List Style

      Organize every course in List order with list layout of the theme

      rich-img

      Course Categories

      Show a single course with Single category layout style crafted with Elementor

  • Pages 
    • rich-img

      About Us

      Know about our business history and our team

      rich-img

      Careers

      Take the next step of your career journey with us

      rich-img

      Become a Teacher

      Train the next generation of tech students

      rich-img

      Success Stories

      Our students success, our pride

      rich-img

      Help Center

      Free resources & support to grow your business

      rich-img

      FAQ

      Free resources to help you grow your business

    • About Us
    • Become a Teacher
    • Careers
    • Help Center
    • FAQ
  • Blog 
    • Latest post

      June 3, 2020

      Make The Leap To Digital Illustration: 7 Drawing Apps
      Read more
      Manager content hub
      rich-img

      Blog Articles

      Smart and simple advice and tools to help you be a better leader for your team

      rich-img

      Grid Style

      Articles and our latest thinking on onboarding, employee experience and more

      rich-img

      Blog Masonry

      Articles and our latest thinking on onboarding, employee experience and more

    • Blog List
    • Blog Grid
  • Contact

© Tophive 2020

  • Home
  • Blog
  • Typing Next.JS components using TypeScript

Login

Lost your password?

Not Registered? Sign up

Sign Up

  • The password should be at least twelve characters long. To make it stronger, use upper and lower case letters, numbers, and symbols like ! " ? $ % ^ & )

Already registered? Signin

Typing Next.JS components using TypeScript

Tophive TeamTophive Team- May 18, 2020- Web Development- 2 Comments

FunctionComponent

In this article, we’ll talk about typing Next.JS components. We’ll be using this Next.JS application that connects to Reddit API and displays a list of top posts in a given subreddit. Right now, the main component Posts.tsx doesn’t have any type-safety, so we’re going to fix that.

Note: the project already contains TypeScript configured, so if you don’t know how to do that, please read the official guide here, it’s as easy as installing a few dependencies and dropping in some configuration files.

If we write our components as functions, we can use FunctionComponent type from React library. This type takes a generic type argument that describes the shape of the props. Our Posts component takes a subreddit name and a list of posts, so props object is going to look like this:

One thing that makes Next.JS components different is a static getInitialProps function. If we try to assign it to our regular React component, we’ll get a type error: To fix this problem, we need to use a special component type from Next.JS package called NextFunctionComponent. This type extends standard React’s FunctionComponent type with Next.JS-specific static lifecycle methods (well, only one method, really). So now our code will look like this:

Do you have any tips for students?
  • Having contacts is the key , you have to develop your network, be friendly and polite;
  • Be authentic : we never know who we can fall, sometimes affinities are created and we eventually find ourselves working with the person. My graphics jobs were obtained through contacts who were already working internally. Do
    not minimize the development of your contacts during your studies.
  • Be 100% yourself! As much in your designs as in your portfolio, or during interviews. Most employers hire you if they feel that you will bring a good attitude and good energy to the team.
  • Everything can be learned! Indesign (the layout software) was my weak point, and yet, I was engaged in editing! Do not be afraid to apply to places outside of your comfort zone , if the employer hires you, it is because he knew how to see your potential and he will take the time to teach you.
  • True fact : The most pleasant jobs are not the ones that pay the most (even if publishing is a dream for many, unfortunately the salary is not as good as a job in web or animation that will bring more ).
  • Enjoy ! I am still young (25 years old), so I take the opportunity to try different things and aspects of the job! Do the same!

I participate in beautiful projects that are close to my values. I am extremely grateful to be in such a great team!

© Black and white portrait photo credits: Lola Meunier

Code, Next.JS, TypeScript, Web Design
Share this post
Tophive Team
About The Author

Tophive is an agency with top talented designers and developers crowd. Our team of 7 includes UI and UX designers, Front-end, and back-end developers. The team has extensive experience in building high-quality websites for MNC as well as agencies from the local and global territory.

View all post by Tophive Team | Website

Post navigation

Previous Previous post: prev-postWhat does the future of learning look like?
Next Next post: next-postMake The Leap To Digital Illustration: 7 Drawing Apps

2 Comments

  1. Tophive Team
    Tophive
    September 23, 2020 at 5:46 am
    Reply

    It seems like NextFunctionComponent has been renamed to NextComponentType in current releases of Next.JS

  2. Joseph Phillips
    September 23, 2020 at 5:49 am
    Reply

    I’d be great to have an updated version of this post. As it was real helpful starting out.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Solutions

  • Google Analytics Certification
  • Digital Marketing Masterclass
  • CompTIA Network
  • Character Drawing
  • Network Engineers
  • Web developer Bootcamp
  • AWS Certified Solutions
  • Communication Skills

Learning

  • Business
  • Development
  • IT & Software
  • Marketing
  • Design
  • Photography

About

  • Our Story
  • Resource Center
  • MasterClass for Business
  • Get The App

© 2023 Main Demo – Powered by masterclass.