0

I am having trouble getting a boolean value from a separate component file to display properly in my main App.js file.

I created a separate file called Component.js where I defined a boolean variable called "test" and exported it. In App.js, I imported the variable and logged it to the console. However, the console is showing me the entire Component function definition instead of the boolean value.

This is my App.js:

import React, { useState } from "react";
import "./App.css";
import test from './Component'

export default function App() {
  console.log(test)
  return (
    <>
   </>
  )
}

This is my Component.js

import React, { useState } from "react";

export const test = true;

export default function Component() {

}
inkredusk
  • 919
  • 4
  • 16

1 Answers1

2

You have imported the default export import only test module

import React, { useState } from "react";
import "./App.css";
import { test } from './Component'

export default function App() {
  console.log(test)
  return (
   <>

   </>
  )
}
Srushti Shah
  • 810
  • 3
  • 17