website – React app with express server as proxy implementation

I have the whole react page ready and just installed express js as a back end (more like a proxy for the api calls). The reason I wanted to have express is to “hide” any api calls I do to the third party websites from the front end. So basically instead of using axios and calling 10 apis which will be visible in the network tab, I call just 1 api to the express and the express does it all in the background nice and clean.

The issue is that the express runs within the react app, but I am planning on separating the express as a whole new project and leave react app on its own and host them both separately.

The question I have to someone who did this kind of stuff: Is it worth doing this and how save and stable this solution is? By hosting the server separately and running it is save? Because if something happens with the express project and crashes, the whole website is dead as it will not be able to call that 1 api and get the data back where by having axios on the front end I can handle any crashes.

javascript – How Do I Display My React Application on the LocalHost after making revisions?

Good evening,

I have been learning Front End Web Development with React through Coursera.org. While I have part of one foot inside the door with the knowledge of web design I acquired previously through Coursera.org, React is all new to me.

Somehow through a lot of trial and error and watching over and over again the videos of the lectures on how to install the react app, I managed to display the react app at the beginning. But the webpage was blank it did not have any design or text in it. Once I started to add the code that the professor was providing us in the videos, everytime I saved the changes and checked the localhost, it kept displaying an error page. When I completed the first assignment, of course the my React app was not displaying, but I passed the assignment.

Now I am on my second assignment and I need to see if what my professor wants me to display on the React app through the instructions given displays. I need to see whether the code that I research and the revisions that will make as a result of the research is correct. Right now I feel I am blinded because i cannot see if whatever code I try works.

What I am planning to do for this Assignment 2 is go over the lectures prior to Assignment 1 so that I can try to reinstall the app and also pin point what is wrong with the code I submitted in Assignment 1. But also I can only assume that I must have made a lot of mistakes copying the code the professor gave me in the videos from the first week of lessons.

Right now, I do not have a working React App.

Any suggestions are greatly appreciated.

Millie

maps – Geolocalização com React Native

Estou tentando pegar a minha latitude e longitude, para isso utilizei o seguinte código:

import { View, Text, TextInput, StyleSheet, TouchableOpacity } from 'react-native';
import MapView, { PROVIDER_GOOGLE } from 'react-native-maps';
import { Marker } from 'react-native-maps';
import Geolocation from '@react-native-community/geolocation';

export default function Map({ navigation }) {
    
    const (latitude, setLatitude)=useState(0)
    Geolocation.getCurrentPosition(data=>{
        setLatitude(data.coords.latitude)
    });

    const (longitude, setLongitude)=useState(0)
    Geolocation.getCurrentPosition(data=>{
        setLongitude(data.coords.longitude)
    });

    return (
        <MapView
            provider={PROVIDER_GOOGLE}
            region={{
                latitude: latitude,
                longitude: longitude,
                latitudeDelta: 0.0042,
                longitudeDelta: 0.0031,
            }}
            style={styles.mapView}
            rotateEnabled={false}
        >
            <Marker
                coordinate={{
                    latitude: latitude,
                    longitude: longitude
                }}
            />
        </MapView>
    );
}
const styles = StyleSheet.create({
    mapView: {
        flex: 1,
    }
})

Ele me retorna uma latitude e longitude, porém não são da minha posição atual, é de um outro local (outra cidade nos USA), preciso da latitude e longitude para armazenar em um BD que já possuo.

sharepoint online – SPFX – React – list / listItem/ page is undefined in this.context.pageContext

I am creating SPFX web part with React.

In which I am trying to get the current page ID on which webpart is added. I was trying to check if I can get it directly from the page context.

I am getting page context using this.context.pageContext but I noticed some of the properties are undefined.

like this.context.pageContext.list, this.context.pageContext.listItem, this.context.pageContext.page these are undefined.

Could any one please tell me the reason behind this. OR please guide me on how to get the ID of the page on which web part is added.

Thanks a lot.

Converter Class Based Component para React Hooks

Sou novo no React Native e estou com dificuldade em converter este código abaixo feito em Class Component para React Hook:

import React, { Component } from 'react';
import ReactDOM from "react-dom";

// create and get reference to Modal DOM node
const appRoot = document.getElementById('root');
appRoot.insertAdjacentHTML('afterend', '<div id="modal-root"></div>');
const modalRoot = document.getElementById('modal-root');

class InnerModal extends Component {
  constructor(props) {
    super(props);
    this.el = document.createElement('div');
  }

  componentDidMount() {
    // https://reactjs.org/docs/portals.html

    // The portal element is inserted in the DOM tree after
    // the Modal's children are mounted, meaning that children
    // will be mounted on a detached DOM node. If a child
    // component requires to be attached to the DOM tree
    // immediately when mounted, for example to measure a
    // DOM node, or uses 'autoFocus' in a descendant, add
    // state to Modal and only render the children when Modal
    // is inserted in the DOM tree.
    modalRoot.appendChild(this.el);
  }

  componentWillUnmount() {
    modalRoot.removeChild(this.el);
  }

  render() {
    const containerStyle = {
      // copied from RNW View/StyleSheet/constants
      alignItems: 'stretch',
      border: '0 solid black',
      boxSizing: 'border-box',
      display: 'flex',
      flexBasis: 'auto',
      flexDirection: 'column',
      flexShrink: 0,
      marginTop: 0,
      marginRight: 0,
      marginBottom: 0,
      marginLeft: 0,
      minHeight: 0,
      minWidth: 0,
      paddingTop: 0,
      paddingRight: 0,
      paddingBottom: 0,
      paddingLeft: 0,
      position: 'relative',
      zIndex: 0,

      // modal
      position: 'absolute',
      left: 0,
      top: 0,
      right: 0,
      bottom: 0,

      // etc
      backgroundColor: this.props.transparent ? 'transparent' : 'white',
    };

    return ReactDOM.createPortal(
      <div style={containerStyle}>
        {this.props.children}
      </div>,
      this.el,
    );
  }
}

export 

reactjs – How to import a markdown file with React markdown-to-jsx

I do not know how to import a markdown file with react markdown-to-jsx

constructor(props) {
    super(props);
    this.state = {  }
}
render() { 

    return ( <div><File /><Markdown>asd </Markdown> </div>);
}

}

as you can see above but I want something like

constructor(props) {
    super(props);
    this.state = {  }
}
render() { 

    return ( <div><File /><Markdown source="./markdownfile.md"> </Markdown> </div>);
}

}

react – acessar servidor de desenvolvimento em uma maquina virtual na nuvem (Vue e ReactJS)

Tenho um pc antigo e não consigo rodar o servidor de desenvolvimento do Vue ou do ReactJS e um editor de código fonte, além do browser sem o pc ficar travando.

Tive a ideia de criar uma maquina virtual no Google Cloud e rodar o servidor lá e editar os arquivos via SSH, o VScode permite isso, rodou tudo certo, mas o problema é que preciso ficar dando build nos aplicativos pra rodar com um servidor Python e conseguir acessar no navegador.

Quero saber se é possível acessar o servidor de desenvolvimento já que ele faz o build automático porque os build manual levam muito tempo e da muito trabalho fazer tudo e não consigo acompanhar em tempo real o que eu tô fazendo.

Pesquisei bastante e não encontrei nada que me ajudasse de fato.

javascript – How to access index of .map() method outside of it in react

I want to access the index number outside of that map method because I want to use that index conditionally to show other component like if that index is checked then the component will show but I can’t figure out how to access that outside of that map method. I have googled it but couldn’t find any proper solution of that.

Here is my code!

import React, { Component, Fragment } from "react";
import Clear from "./clear";
import Display from "./display";
import NoOfItems from "./noOfItems";

class MainPage extends Component {
  constructor() {
    super();
    this.state = {
      data: (
        {
          name: "",
          completed: false,
        },
      ),
      data: (),
      checkValue: false,
    };
  }

  handleChange = (e) => {
    e.preventDefault();

    this.setState({ name: e.target.value });
  };

  handleSubmit = (e) => {
    e.preventDefault();

    this.setState({
      data: (...this.state.data, { name: this.state.name, completed: false }),
    });
    e.target.reset();
  };

  handleDelete = (index) => {
    const newList = (...this.state.data);
    newList.splice(index, 1);

    this.setState({ data: newList });
  };

  handleAllCheck = (e) => {
    e.preventDefault();
  };

  handleCheckChange = (index) => {
    let newData = (...this.state.data);
    newData(index).completed = !newData(index).completed;
    this.setState({ data: newData });
  };

  render() {
    return (
      <Fragment>
        <h1 className="display-1 text-center" style={{ color: "#f7c6c6" }}>
          todos
        </h1>
        <form className="todo-form" onSubmit={this.handleSubmit}>
          <label className="label" onClick={this.handleAllCheck}>
            ^
          </label>
          <input
            autoFocus
            type="text"
            onChange={this.handleChange}
            className="new-todo shadow-lg p-3 mb-5 bg-white"
            placeholder="What needs to be done?"
          />
          <ul className="list-group">
            {this.state.data.map((data, index) => {
              return (
                <div key={"todo-" + index} className="div-list">
                  <input
                    className="check"
                    onChange={() => this.handleCheckChange(index)}
                    type="checkbox"
                    style={{
                      cursor: "pointer",
                    }}
                    defaultChecked={this.state.data.completed}
                  />
                  <li
                    className="list-group-item disabled w-50 p-3 mx-auto"
                    style={{
                      textDecoration:
                        this.state.data(index).completed && "line-through",
                    }}
                  >
                    {data.name}
                  </li>
                  <button
                    onClick={() => this.handleDelete(index)}
                    type="button"
                    className="close"
                    aria-label="Close"
                  >
                    <span aria-hidden="true">&times;</span>
                  </button>
                </div>
              );
            })}
          </ul>
          {this.state.data.length > 0 && <Display />}
          {this.state.data.length > 0 && (
            <NoOfItems noOfTodos={this.state.data.length} />
          )}
          {this.state.data.completed && <Clear />}
        </form>
      </Fragment>
    );
  }
}

export default MainPage;

Just ignore the rest and see the map method and its index. At the end of the code I have used this.state.data.completed at this point I want to use the index like this this.state.data(index).completed but its saying invalid declaration of Index. Please help me I am stuck!

Thank you in advance!

php – Pdf React Native

Possuo uma api em laravel que transforma um arquivo pdf em base64. Gostaria de saber se é possível eu pegar esse base64 no react native e transformar ele em pdf novamente, e como pode ser realizado essa ação

windows – React and NodeJS deployment issue on linux server

I have a web application created using ReactJS , NodeJS and Mongo DB on windows. And I am facing issues while deploying the same application on a Linux Server in AWS. Is there any changes to be considered while deploying such?

Is there any changes that needs to be done for the code? Does the path declaration change on the config file?

getting such errors?
ENOENT: no such file or directory, stat ‘/home/ec2-user/Project/Backend/Backend/client/build/index.html'”