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() {

}
0

1 Answer 1

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 (
   <>

   </>
  )
}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.