Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 303
Kilbo Avatar asked Jan 26 '26 08:01

Kilbo


1 Answers

{ 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.

like image 174
Loki Avatar answered Jan 28 '26 22:01

Loki



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!