I have a components directory in src which has a directory called calculator and then it has 3 different components, instead of importing all 3 I was thinking if I can just import the directory calculator.
one of component has following code
import React from 'react';
import {Textfit} from 'react-textfit';
const Screen = (props) => {
return (
<div className="screen--container">
<Textfit
max={40}
throttle={60}
mode="single"
className="screen-top"
>
{ props.expression }
</Textfit>
<Textfit
max={150}
mode="single"
className="screen-bottom"
>
{ props.total }
</Textfit>
</div>
)
}
export default Screen;
And then in my App.js I have
import React, { Component } from "react";
import Calculator from "./components/calculator";
import "./App.css";
class App extends Component {
render() {
return (
<div className="calculator--container">
<Calculator.Screen {...this.props} />
<Calculator.Keypad {...this.props} />
</div>
);
}
}
export default App;
But currently its giving me an error as below ./src/App.js Module not found: Can't resolve './components/calculator' in 'C:.....\react-simple-calculator\src'
How can I make this work?
Also, the original code from developer had
export default (props) => {
return ()}
but I have changed it to
const Screen = (props) => { }
export default Screen;
Is that correct, what does the first one mean? The code am referring to is : https://medium.com/@mazinosukah/lets-build-a-calculator-with-redux-and-react-using-tdd-6cb11946bad4