0

I'm new to React and I have written some API call in component and when I try to add the imports in my main component it shows following error ERROR in ./src/containers/Ready_bricksapi.jsx Module not found: Error: Can't resolve 'exports' in 'D:\Brickzle (1)\src\containers'

@ ./src/containers/Ready_bricksapi.jsx 1:0-65

@ ./src/containers/homepage.jsx

@ ./src/containers/app-route.jsx

@ ./src/entry-points/client.jsx

@ multi webpack-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/entry-points/client.jsx

import React, { Component } from 'react';


export  class ReadyBricks extends Component {
   Constructor(props) {
     Super(props);
     this.setState = {
       bricksList: []


     };


   }
  componentDidMount() {
    this.readyBrick();
  };

     readyBrick() {
     console.log("inside get api");
     const url = '\'http://10.10.1.42:8070/api/user/brick/getBrickList?id=0\'';
       fetch(url, {
         method: 'GET',
         headers: {
           'Content-Type': 'application/json',
           'auth':'sdf345dvdfg4dfgdf435fghfhfg45123'
         },
       })
         .then(function (response) {
           let bricksList=response.results;
           return bricksList;
           console.log(bricksList);
         })

         .catch(function(error) {
           console.log(JSON.stringify(error));
         });





     }


  render() {
    const ReadyBricks = this.state.bricksList.map((item) => {
      return <div className="col-xs-12">
        <div className="col-xs-6">
          <p>Ready Brick Arts </p>
          {item}
        </div>
      </div>
    });


  }

 }

now my question is how to add this jsx file into my components

Shota
  • 6,910
  • 9
  • 37
  • 67
arvind grey
  • 150
  • 12

1 Answers1

0

I don't know what you mean by 'payable' - are you offering to pay for advice? I'm not really interested in that.

Here is how you do it. On a page somewhere (usually index.html) you nominate a HTML element to receive the top level render() from React.

Let's say your HTML looks like this

<body>
  <div id="myDiv"></div>
</body>

and in your script you do this:

React.render(
    <ReadyBricks/>,
    document.getElementById('myDiv')
);

So that will render your ReadyBricks component into the myDiv div.

But if you don't know that already, and you want to build things with React, then you really do need to do a course.

Mikkel
  • 7,693
  • 3
  • 17
  • 31