AndrewSunshiny
AndrewSunshiny

Reputation: 11

React.js/Solid.js Import path fallback index.js alternative

You can import file using index.js naming and pointing to folder where is that file.

- src
   App.js
  - Component
     index.js

And when importing it will fallback to index.js

import Component from './Component'

Can I write the same but remaining file named as folder?

Upvotes: 0

Views: 92

Answers (1)

snnsnn
snnsnn

Reputation: 13698

Both React and Solid follows JavaScript's import and export semantics and there are no extra rules or workarounds.

In JavaScript, pointing to a file or folder has no effect, you have to import and export items explicitly and there is no built-in fallback mechanism.

You can learn more about ES6 module rules at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules.

Upvotes: 0

Related Questions