Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

174
Views
Which way should I import React?

I'm not sure which way I' supposed to import React in my React Native app. If I need to use a hook like useState should I import React with: import React, { useState } from 'react';, import { useState } from 'react';, import * as React from 'react';, or import * from 'react';? If I don't need any hooks should I use: import React from 'react';, import 'react';, import * as React from 'react';, or import * from 'react';?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

As of react version 17+, you don't need to import React from 'react' anymore. Read more about the JSX transformation.

Hooks are named exports, so you need to import hooks as:

import {useState, useEffect /* and others */} from 'react'

If you are using a react version below 17, you need to import React. Since React would be a default import these are all refer to the same thing:

import React from 'react'
import * as React from 'react'

So you should do import React, {/* hooks you are using */} from 'react'.

You can even do import * as Whatever from 'react', since it is not a named export.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!