Kilbo
Kilbo

Reputation: 365

React.Fragment only works with import React (not with import { React })

For some reason if I try and use <React.Fragment> with

import { React, useState, useEffect } from 'react'

at the top of my page I get

Uncaught TypeError: Cannot read properties of undefined (reading 'Fragment')

If I switch this to

import React, { useState, useEffect } from 'react'

it works just fine. Is this indicative of a problem somewhere else?

Upvotes: 3

Views: 740

Answers (1)

Loki
Loki

Reputation: 41

{ React } is worng usage.
If you use typescript the error will be shown right away. TS Error check this link to see the exact error you are facing and its solution.

Upvotes: 2

Related Questions