react: help create a component MENU [reactjs]

Good day!
It may seem that maybe I am looking to reinvent the wheel, with a number of components available for use. But I was challenged to create my own menu. Just to learn Perhaps this reason justifies wasting time "reinventing the wheel."
I thank those who can help me.
Let's go to the problem:

Menu configuration file:

export default {
items: (
    {
        name: 'Home 1',
        url: '/',
    },
    {
        name: 'Pré-inspeção',
        url: '/pre-inspecao/',
        children:(
            {
                name: `Planejamento`,
                url: '/planejamento/',
                children:(
                    {
                        name: 'Nova Inspeção',
                        url: '/pre-inspecao/nova',
                    },
                    {
                        name: 'Inspeções',
                        url: '/pre-inspecao/lista',
                    },
                )
            },
            {
                name: 'Equipe',
                url: '/equipe/',
                children:(
                    {
                        name: 'Inspeções',
                        url: '/equipe/inspecao/lista',
                    }
                )
            }
        )
    },
)

}

Item management file and menu assembly (trial version)

import React from 'react'

import navConfig from & # 39; ../../ Route / navConfig.jsx & # 39;

SideBarMenu default export function ()
{

//console.log(navConfig);

const {items} = navConfig;

const menu = '';

var strAux = ''

function criaMenu(items)
{

        items.map(function(item, i)
            {
                strAux += "
    " adicionaItemMenu(item); strAux += "
" } ) return strAux; } function adicionaItemMenu(item) { // console.log('adiciona') // console.log(item) // console.log('fim - adiciona') if(item.children && item.children.length > 0) { // console.log('---') // console.log(item.children) strAux += "
  • " + item.name + "
  • " item.children.map(function(itemAux,i) { strAux += "
  • " criaMenu((itemAux)) strAux += "
  • " } ) //criaMenu((item)) } else{ strAux += "
  • " + item.name + "
  • " } } return( criaMenu(items) )

    }

    This trial version is working. She returns me a rope with all the ulbe liThey are positioned correctly. but I would really like it to return the html elements and such. So I tried to rewrite it to achieve the goal, and it is in this second version that I have problems, I do not know if it is difficult to be a beginner, try an incorrect implementation concept, or even for the two previous reasons kkkkk
    Follow the code:

    import React from 'react'
    

    import navConfig from & # 39; ../../ Route / navConfig.jsx & # 39;

    SideBarMenu default export function ()
    {

    //console.log(navConfig);
    
    const {items} = navConfig;
    
    const menu = '';
    
    var strAux = ''
    
    function criaMenu(items)
    {
        return(
            items.map(function(item, i)
                {
                    
      { adicionaItemMenu(item) }
    } ) ) } function adicionaItemMenu(item) { // console.log('adiciona') // console.log(item) // console.log('fim - adiciona') if(item.children && item.children.length > 0) { // console.log('---') // console.log(item.children) return(
  • {item.name}
  • { item.children.map(function(itemAux,i) {
  • { criaMenu((itemAux)) }
  • } ) }
    ) } else{ return(
  • {item.name}
  • ) } } return(
    { criaMenu(items) }
    )

    }

    Therefore, I receive this error message:

    ** Error compiling

    ./src/Components/SideBarMenu/index.jsx

    Line 21: expected an assignment or function call and, instead, saw an expression without unused expressions

    Line 47: I expected an assignment or function call and, instead, saw an expression without unused expressions

    Search the keywords for more information about each error. **

    Once again, I leave my thanks to those who try to help.
    See you soon!

    javascript – How to add a custom horizontal line to react with the wysiwyg editor?

    I will try to add a costom button,


    tag to react-draft-wysiwyg using redux. After reading a documentation and a trial and error method, I got caught. I will create a custom button and add it to the editor:

    
      )}
    />
    

    I am reading about two possible solutions, first:

    add a new blocking line, if the HR button is clicked using the method, and pass them to the Editor as blockRendererFn:

    addHorizontalLine = contentBlock => {
      const type = contentBlock.getType();
      if (type === "atomic") {
        return {
          component: HorizontalLine,
          editable: false
        };
      }
    };
    

    It didn't work, the type of case is not atomic. If I change the condition to the tests to the current type ("no style"),


    The component was shown, but only once, nothing changes when you click on the HR button.

    Second:

    create custom contentBlockType, for example "HORIZONTAL_RULE" and pass the rule to the Editor in the same way.

    addHorizontalRule = editorState => {
      const contentState = editorState.getCurrentContent();
      const contentStateWithEntity = contentState.createEntity(
        "HORIZONTAL_RULE",
        "IMMUTABLE"
      );
      const entityKey = contentStateWithEntity.getLastCreatedEntityKey();
       return AtomicBlockUtils.insertAtomicBlock(editorState, entityKey, " ");
      };
    

    For me, the second attempt makes more sense, but to be honest, I don't know what's next.

    Complete example of codesandbox: https://codesandbox.io/s/reactredux-6nhc8

    reactjs – How to solve this error with npm run for react?

    I received an error when I made npm start to react from the beginning.

    Please help me solve it

    (base) jakes-air:try_app juyounglee$ npm start
    
    npm ERR! file /Users/juyounglee/Documents/try_app/package.json
    
    npm ERR! code EJSONPARSE
    
    npm ERR! JSON.parse Failed to parse json
    
    npm ERR! JSON.parse Unexpected token } in JSON at position 259 while parsing near '...t-scripts build",
    npm ERR! JSON.parse   },
    
    npm ERR! JSON.parse   "eslintConfig":...'
    
    npm ERR! JSON.parse Failed to parse package.json data.
    
    npm ERR! JSON.parse package.json must be actual JSON, not just JavaScript.
    
    npm ERR! A complete log of this run can be found in:
    
    npm ERR!     /Users/juyounglee/.npm/_logs/2019-09-12T19_24_04_265Z-debug.log
    

    javascript: editable entries in React that can be exchanged with a button

    Part of my page involves entering numbers and allowing them to be editable and interchangeable. Calculations are made on numbers, so calculations should only be made when the entries are blurred. The values ​​in the tables must be updated when the values ​​are exchanged. However, they must also be editable. I'm new to React, so this is the best thing that occurred to me, but it feels very clumsy and repetitive. I would really appreciate any advice on style and efficiency.

    import React from 'react';
    import ReactDOM from 'react-dom';
    import './index.css';
    
    
    class Calculator extends React.Component {
      constructor(props) {
        super(props);
    
        this.state = {
          num1: null,
          num2: null,
          box1: null,
          box2: null,
        };
    
        this.handleNumChange = this.handleNumChange.bind(this);
        this.handleNumInput = this.handleNumInput.bind(this);
        this.handleSwap = this.handleSwap.bind(this);
      }
    
      handleNumChange = (event, key) => {
        this.setState({
          (key): event.target.value,
        });
      }
    
      handleNumInput = (event, box) => {
        this.setState({
          (box): event.target.value,
        })
      }
    
      handleSwap = (event) => {
        this.setState({
          num1: this.state.num2,
          num2: this.state.num1,
          box1: this.state.num2,
          box2: this.state.num1,
        });
      }
    
      render() {
        return (
          
    ); }; } function NumberBox(props) { return (
    ) } function NumberPrompt(props) { return ( ); } function SwapButton(props) { return ( ); } function Output(props) { return (
    {`Number 1 is ${props.num1} and Number 2 is ${props.num2}`}
    ); } // ==================================================== ReactDOM.render( , document.getElementById('root') );

    Edit: I realized that I had NumberPrompt & # 39; s as id instead of className. I fixed it in my code.

    How to enable CORS in Sharepoint Online with the react application

    I am trying to implement the shared point file explorer in my reaction application. Using microsoft/file-browser For this ans code as follows. But get the xxx... from origin 'http://localhost:3000' has been blocked by CORS policy

    Any idea how I can enable CORS for this

    import * as React from "react";
    
    import { GraphFileBrowser } from '@microsoft/file-browser';
    
    class App extends React.Component {
    
    
      getAuthenticationToken() {
        return new Promise(resolve => {
          resolve(
            "VALID TOKEN"
          );
        });
      }
    
      render() {
        return (
           console.log(selectedKeys)}
            onCancel={(err: Error) => console.log(err.message)}
            endpoint='https://XXX.sharepoint.com'
    
          />
        );
      }
    }
    
    export default App;
    

    reactjs – react table: update the table after receiving new data

    I want to update my reaction table after receiving new data. I was hoping to activate this when I change status, however, it doesn't work. The status and update function are shown below.

    this.state = {
            switchListSelected: (),
            switchListData: (),
            interfaceStatusData: (),
            interfaceErrorsData: ()}
    
    updateParentState(data, element){       
        this.setState(prevState => {
            return prevState(element).push(data)}}
    

    sharepoint online – spfx webpart react rest api

    I am using the REST API in my SPFx web part and I pass the parameter in the REST API but it does not work as expected, there is some error writing the REST API into “ since the parameter does not work:

    url: `${this.props.siteurl}/_api/web/lists/getbytitle('Templates')/items?$select=Title,CurrentLink,HistoricalLink,DataGroupTemplate/Template&$expand=DataGroupTemplate&$filter=DataGroupTemplate/Template eq'"+a+"'`
    
    

    Typing – How to change only one component on the screen using transition / navigation / router in React Native

    I have 3 components that I want to show in sequence. When I click on a button on the first component, I switch to the next component, and when I click on a button on the second component, I switch to the third component.

    I need to change only one lower component on the main screen, I prefer to use a custom transition (from right to left). It's possible?

    Here is an example of what I want to do, but only between components:
    https://medium.com/async-la/custom-transitions-in-react-navigation-2f759408a053

    javascript – How to implement Adonis JS version 4.1 WebSocket with React JS

    Goodnight.
    After a full day of research, both in Portuguese and English, I decided to post my question here.

    How do I implement React JS + Adonis JS using WebSocket in a microservice-based application?
    Note: I could do what I wanted directly in Adonis, that is, use its structure. But that is not my goal, since I will only use Adonis as a backend (ApiOnly).

    I was able to communicate even from a php file created with Adonis, but also, this is not my goal, my goal is to create an application using React JS with Adonis Js socket patterns.
    I hope you understand. From now on, thank you very much for your attention.

    What is the best UI component library for the native mobile application React?

    I am a beginner for the reaction native, I want to start designing the mobile application of the reaction native e-commerce, but start before I want to know some information about the user interface components. I read this article, I want to design as a user interface of the Aliexpress mobile application, anyone knows the best user interface components for the design that.

    and anyone knows the uber application to use the component structure of the user interface

    Thank you