-
Notifications
You must be signed in to change notification settings - Fork 49
Open
Labels
good first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is needed
Description
Hi there,
I'm trying to use forgJS with create-react-app but unfortunately it raise the error:
1!] Error: 'Rule' is not exported by node_modules/@cesium133/forgjs/index.js
this is how I used:
import * as React from 'react';
import { Rule } from '@cesium133/forgjs';
import styles from './styles.css';
const ExampleComponent = ({ text }: any) => {
const floatRule = new Rule(
{
type: 'float',
min: 100,
},
null
);
const result = floatRule.test(200.3);
console.log(result);
return <div className={styles.test}>Example Component: {text}</div>;
};
export default ExampleComponent;
To have a working example is enough to do:
npx create-react-library
and then install the package forgJs.
Can someone help me on that please?
Metadata
Metadata
Assignees
Labels
good first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is needed
Projects
Milestone
Relationships
Development
Select code repository
Activity
oussamahamdaoui commentedon Jul 16, 2019
Hello, i haven't tried it but you should try
import Rule from '@cesium133/forgjs';
tell me if this solves your problemdaniele-zurico commentedon Jul 16, 2019
No it doesn’t
oussamahamdaoui commentedon Jul 16, 2019
this worked for me can you give me more information i dont get the problem that you got
daniele-zurico commentedon Jul 16, 2019
Are you sure you tried on ‘npx create-react-library’ I realised on the title I put the CRA that is the wrong one
oussamahamdaoui commentedon Jul 16, 2019
can you tell me the steps you went thought i did:
1-
npx create-react-library
2- named it pr
3- went to the pr folder
4- did npm i @cesium133/forgjs
5- changed the exemple component to use forgjs
6- did npm start
i didn't get any problem
daniele-zurico commentedon Jul 16, 2019
1-
npx create-react-library
2- pr
3- npm
4- typescript
5-
cd pr
6-
cd src
7-
replace the content of index.tsx
8-
npm start
Error:
The folder you edit is the demo folder that is the project that run your library
oussamahamdaoui commentedon Jul 16, 2019
Apparently imports dont work with type script you can use require it worked for me try this and tell me if you get errors:
const { Rule } = require('@cesium133/forgjs');
daniele-zurico commentedon Jul 16, 2019
Unfortunately is not correct! Import works really well with typescript. I tried to use it in a CRA create-react-app newtest —typescript.
Not sure what stop it to work over here instead
oussamahamdaoui commentedon Jul 16, 2019
Did the require work for you ?
daniele-zurico commentedon Jul 16, 2019
It create a circular recoursion on the demo. However I don’t think require is the best solution
oussamahamdaoui commentedon Jul 16, 2019
Id keep looking. Please tell me if you find a fix for this