GithubHelp home page GithubHelp logo

react-components-as-routes's Issues

some confusing things about this walkthrough

There's a couple of things that seem to be a little out of order/need tweaking.

There's this code snipet that is explained afterwards:

// .src/index.js
 
import React from 'react';
import ReactDOM from 'react-dom';
// Step 1. Import react-router functions
import { BrowserRouter as Router, Route } from 'react-router-dom';
 
const App = () => {
  return (
    <div>
      <h1>Home</h1>
    </div>
  );
};
 
// Step 2. Changed to have router coordinate what is displayed
ReactDOM.render((
  <Router>
    <Route path="/" component={App} />
  </Router>), 
  document.getElementById('root')
);
The description then goes on to say:

We are using the render prop in the Route component, but we could have used component={Home} instead. With render we are just invoking a function call to render <div><h1>Home</h1></div>.

The issue is when you talk about using the render prop in the Route component.

Then he next code snipet is:

// ./src/index.js
import React from 'react';
import ReactDOM from 'react-dom';
import { BrowserRouter as Router, Route } from 'react-router-dom';
 
const App = () => {
  return (
    <div>
      <Router>
        <Route exact path="/" render={() => <h1>Home</h1>} />
      </Router>
    </div>
  );
};
 
ReactDOM.render(
  <App />, 
  document.getElementById('root')
);

It seems to me that this code snipet is the one the first one should be. ?

Also later on in the walkthrough there's this:

NAVLINKS
What good are routes, if users don't know how to find them or what they are?
The React Router API comes with two options of adding in Links: and . The both have the same base level functionality...

This seems unclear as to what the two options for adding links are.

@BriOD originally posted here: learn-co-students/react-components-as-routes-v-000#12 (comment)

@Lukeghenco is this something you might be able to take a look at?

npm ERR! notarget It was specified as a dependency of 'cosmiconfig'

This lesson had a dependency that used require-from-string, an NPM package published by floatdrop, who recently deleted his NPM account, taking all his NPM packages with it. Currently, there is a work around by directly installing the package from his github using the following command in the lesson root directory:

npm install https://github.com/floatdrop/require-from-string/tarball/v1.1.0 --save
npm install

Can't get `npm start` to run due to issues with package.json

I've spent thirty minutes trying to get npm start to run, and it just keeps giving me different errors about dependencies. I've tried running npm install npm audit fix npm update and deleting the package-lock.json file. I can't get get anything to work.

Here's an example of the error messages I'm seeing:

❯ npm start

> [email protected] start /Users/helloamandamurphy/Development/code/Labs/react-components-as-routes-v-000
> react-scripts start


There might be a problem with the project dependency tree.
It is likely not a bug in Create React App, but something you need to fix locally.

The react-scripts package provided by Create React App requires a dependency:

  "babel-loader": "8.0.6"

Don't try to install it manually: your package manager does it automatically.
However, a different version of babel-loader was detected higher up in the tree:

  /Users/helloamandamurphy/Development/code/Labs/react-components-as-routes-v-000/node_modules/babel-loader (version: 6.4.1) 

Manually installing incompatible versions is known to cause hard-to-debug issues.

If you would prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That will permanently disable this message but you might encounter other issues.

To fix the dependency tree, try following the steps below in the exact order:

  1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
  2. Delete node_modules in your project folder.
  3. Remove "babel-loader" from dependencies and/or devDependencies in the package.json file in your project folder.
  4. Run npm install or yarn, depending on the package manager you use.

In most cases, this should be enough to fix the problem.
If this has not helped, there are a few other things you can try:

  5. If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
     This may help because npm has known issues with package hoisting which may get resolved in future versions.

  6. Check if /Users/helloamandamurphy/Development/code/Labs/react-components-as-routes-v-000/node_modules/babel-loader is outside your project directory.
     For example, you might have accidentally installed something in your home folder.

  7. Try running npm ls babel-loader in your project folder.
     This will tell you which other package (apart from the expected react-scripts) installed babel-loader.

If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That would permanently disable this preflight check in case you want to proceed anyway.

P.S. We know this message is long but please read the steps above :-) We hope you find them helpful!

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `react-scripts start`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/helloamandamurphy/.npm/_logs/2019-12-16T22_25_04_019Z-debug.log

I've also tried manually updating the packages and can't get through all of them.
As always, there's a chance it's user error, but I haven't seen this message before.

This is a reading

This is a readme; it should not be looking for you to fork or pass tests

grammar error

Change: "passing a arrow function inside of a render"
To: "passing an arrow function inside of a render

Typo?

The Route component has two props in our example: path and render

I think render should be component in this example.

Spelling error

"Load up the browser again and you should see beautiful blue navlinks that load up the desired component. To get more comfortable, I would recommend implementing /signup and /messages routes that load in compnents, also make sure to add in some NavLinks."

should be components

Confusing instructions

First the lesson says to do this:
"In anticipation of a growing codebase, let's refactor by removing the components we defined in index.js and placing them in their own files in src/."

Then we are given instructions that assume that you did NOT do the above:
"Let's work on adding in the component to our application. For ease of display, we will work as if we still have all of our components in one file. If you have broken them out into individual component files, update accordingly:"

I commented out the files I just created, but that part seems like an unnecessary detour.

Thank you.

Lab won't go away

I have completed the lab and committed it with the green submitted your work showing and I then click the blue I'm done button and the Next Lesson button but it always jumps back to being at the stage of clicking the blue I'm done button. This is the only lab I have in the whole course I cannot complete and it is keeping React from being 100% complete. I would Love if someone could help me resolve this.

grammar error

duplicate "only" in code comment below:

  /* set exact so it knows only to only set activeStyle when route is deeply equal to link */

No console error thrown where error expected as per code along directions

No error thrown, app compiles correctly and does not throw any console errors as expected by code along instructions:

"Following, let's add our /about and /login routes to our router:

// ./src/index.js
 
ReactDOM.render((
  <Router>
      <Route path="/" render={Home} />
      <Route exact path="/about" render={About} />
      <Route exact path="/login" render={Login} />
  </Router>),
  document.getElementById('root')
);

Reload your browser and look at our beautiful routes...oops! Error:

A may have only one child element"

Erroneous and Error-producing Code Block in Example

In the introduction of NavLinks, within the first illustrative code example that defines and assigns const Navbar all of the <NavLink/>s as a whole should be wrapped in a return statement. (line 17)

The other examples further along in this lesson however appear to be correct.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.