Can't import react big calendar - reactjs

Im trying to import the component 'react-big-calendar':
import React from 'react';
import BigCalendar from 'react-big-calendar';
import moment from 'moment';`
could not find a declaration file for module react big calendar
Iv'e already tried to use the npm #Types.. but it didnt work

Are you using private repository or have proxy repository(to cache modules) between your system and npm repository, if yes then add following line in your .npmrc file and then try to check if it works :-
#types:registry = "https://registry.npmjs.com"

You need to install the package from npm:
npm install --save react-big-calendar

Related

Import Issue for React-Table

I am creating a table in react using react-table library. Few days back, I had created a table using the same library and faced no issues. But today I am getting the following error.
Attempted import error: 'react-table' does not contain a default export (imported as 'ReactTable').
Import Statement:
import ReactTable from 'react-table';
I created multiple new projects from scratch and installed the node modules.
Is there any way to resolve this issue?
You need to use the react-table-6
Use this command using Terminal or Command Prompt
> npm i react-table-6 --save
import ReactTable from 'react-table-6';
import 'react-table-6/react-table.css';
Now it will work
I don't know which version of React Table you're using, but looking at the code of the latest version (here), there is no default export, neither a ReactTable export.
It seems that it is now using hooks, so you should use the useTable hook to create a table with the latest version (doc here).
Solved the problem!!!
You have to install
npm install react-table-6
and then import
import React, {Component} from 'react';
import ReactTable from 'react-table-6';
import 'react-table-6/react-table.css';
its solved:)
Reference https://www.npmjs.com/package/react-table-6
You're doing it in the version 6 way, and installing a later version of react-table.
Based on comment found here: React table does not contain a default export, you need to install react-table-6 instead of react-table and replace it as well on your imports.
Anyone having this issue on TypeScript install the below package:
npm install #types/react-table

Import js file from node module with React

I try to add the geojson npm package #mapbox/togeojson.
But i can not use it in my React app. I'm a React/Node beginner, sorry!
First, i ran npm install --save togeojson to install the module and it's well install in node_module folder.
Then, in the React module i try to import geojson.
import togeojson from '#mapbox/togeojson';
And use it:
console.log(togeojson); //undefined
var geoJSON = toGeoJSON.gpx(e.target.result);

Module not found: Can't resolve '#material-ui/core/AppBar'

EDIT: Just discovered that not one single module installed through npm install --save can be resolved. The issue seems to be therefore with all modules even though they are located inside node_modules folder.
I have been debugging this error for the last 2 hours. Note that the application has been created with create-react-app tool.
This is how I am importing the module:
import AppBar from "#material-ui/core/AppBar";
import Button from "#material-ui/core/Button";
import Icon from "#material-ui/core/Icon";
import IconButton from "#material-ui/core/IconButton";
import Tabs from "#material-ui/core/Tabs";
import Tab from "#material-ui/core/Tab";
This is the package.json snippet:
...
"dependencies": {
"#material-ui/core": "^1.5.1",
"#material-ui/icons": "^1.1.1",
...
Try - yarn add #material-ui/core
This resolved the broken dependencies between materialui and react.
Worked for me in my case, it was #material-ui/core/chippedInput that was missing.
The solution that worked for me is the following:
npm install #material-ui/core
Check the link https://www.npmjs.com/package/#material-ui/core
I tried to use material-ui inside a docker container via docker-compose, when I got the same error. I had to reinitialize docker-compose via docker-compose down before running docker-compose up --build. Afterwards the import worked as expected.
I came across this question while trying to work with the material-ui table. Additional to installing the #material-ui/core via npm, make sure you install npm install #material-ui/icons, from https://material-ui.com/getting-started/installation/#svg-icons
What I noticed was, just by npm install it is not installing #material-ui/core package,
we need to install it separately by npm install #material-ui/core. This method is the same for #material-ui/icons
In my case I was following a tutorial and ended up with an import as
import AppBar from 'material-ui/AppBar';
Instead of using the following which is in documentation here.
import AppBar from '#material-ui/core/AppBar';
// or
import { AppBar } from '#material-ui/core';

Can't import Svg icons in material-ui#next

I have upgraded material ui version to v1.0.0-beta.26. With this update I am facing module not found issue when I try to import ActionCircle or any icon as like below.
Eg: import AccountCircle from 'material-ui-icons/AccountCircle';
It seems that you're missing the icons package. Install the material-ui-icons package with this command in terminal:
npm install material-ui-icons --save

How to install/import React in TypeScript

I try to get started with TypeScript and React. Since React is written in JavaScript, I install it using npm
npm install --save react
I need type definitions for React. So I tried
$ typings install react --save
typings ERR! message Unable to find "react" ("npm") in the registry. Did you want to try searching another source? Also, if you want contribute these typings, please help us: https://github.com/typings/registry
typings ERR! caused by https://api.typings.org/entries/npm/react/versions/latest responded with 404, expected it to equal 200
I ran typings search react and found
NAME SOURCE HOMEPAGE DESCRIPTION VERSIONS UPDATED
react dt http://facebook.github.io/react/ 2 2016-05-26T13:46:01.000Z
Hence, I explicitly specified the source
$ typings i dt~react --save
typings ERR! message Attempted to compile "react" as an external module, but it looks like a global module.
I can install React globally
typings install dt~react --save --global
but Atom still complains Cannot find module 'react' when I try to import React
import React from 'react'
How do you install React or configure TypeScript so that you can import React in TypeScript?
The React lib doesn't have a default export. So when you ask it to import React, it looks for a default export in that library. Unfortunately, it doesn't exist. Instead, import the whole contents and namespace in this way:
import * as React from 'react';

Resources