📒
wiki
  • Introduction
  • Coding
    • Git
    • NPM
    • Yarn
    • VIM
    • tmux
    • Terminal
    • HTML
    • Node
    • JavaScript
      • Types
    • TypeScript
    • React
    • Jest
    • FLow
    • Functional programming
    • Data Structures
    • Coding Exercises
    • Design Systems
    • VSCode
  • Learn
    • Languages
  • Health
  • Bikes
  • Ideas
  • Journals/Wiki
  • Looking back
    • 2019
      • September
      • October
      • November
      • December
Powered by GitBook
On this page
  • Type for data-qa attributes
  • Concept of ApiPropsT and PropsT

Was this helpful?

  1. Coding

FLow

Type for data-qa attributes

Example:

type PropsT = {|
  value: ?string,
  onChange: (value: string) => void,
  'data-qa'?: string,
|}

Concept of ApiPropsT and PropsT

An ApiPropsT represents props that are being passed to the React component. A PropsT represents props that are being created inside the React component.

PropsT usually contains spread of ApiPropsT.

Example:

type ApiPropsT = {|
  onChange: (user: UserT) => void,
  user: UserT,
  userEndpoint: string,
  registration: boolean,
|}

type PropsT = {|
  ...ApiPropsT,

  style: StyleT,
|}

function UserDetails({
  user,
  style,
  registration,
  userEndpoint,
  onChange,
}: PropsT) {
  // hooks and state values

  return (/* some JSX*/)

})
PreviousJestNextFunctional programming

Last updated 3 years ago

Was this helpful?