Tim Anderson
Tim Anderson

Reputation: 21

How to use utils.js shared module in Bit components?

We are trying to build a shared React component library in Bit and I'm wondering how others have handled util modules that are called from a component but are not visually rendered. Bit refuses to build, saying that the util module is not a jsx (it shouldn't be a jsx, it's shared utilities for the different components).

In before "that should be a hook" and "creating a non-rendering react component" - it's text / date / etc utility functions.

Thanks for any help!

I tried to include the js file in the component directory, and it refused it because it's a non-rendering, non-.jsx file.

Upvotes: 2

Views: 151

Answers (1)

Jonatan Kruszewski
Jonatan Kruszewski

Reputation: 1286

Identifying the problem

I think that your problem comes from using a react template and not a node.js one.

For example, here you can access the full Bit.cloud "Toolbox", and use as example.

https://bit.cloud/teambit/toolbox/

Steps to create a node component in a new environment

bit new node my-workspace --env teambit.node/node --default-scope my-org.my-scope
bit create node modules/welcome

Documentation

For further reference you can check this link in the docs.

Upvotes: 1

Related Questions