Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Lessons #10

Open
kay-is opened this issue Jun 5, 2018 · 12 comments
Open

New Lessons #10

kay-is opened this issue Jun 5, 2018 · 12 comments

Comments

@kay-is
Copy link
Owner

kay-is commented Jun 5, 2018

While updating to React 16 I saw that some new lessons could be nice.

Styling is only implicitly touched.

Context wasn't a public API until version 16, but now it is.

Some patterns could be nice. Things like Dependency Injection, Higher Order Components and Render Props.

@brandonros
Copy link

Would something about unit testing be worth adding?

@kay-is
Copy link
Owner Author

kay-is commented Jun 29, 2018

Sure, if you can get Jest running in the browser :)

@brandonros
Copy link

Why can't you use just Jasmine? I was under the impression it works fine in the browser on its own.

@kay-is
Copy link
Owner Author

kay-is commented Jul 3, 2018

I didn't look too much into testing or Jest, but I had the impression it was a one-stop-shop.

I just read that you can use Jest assertions and mocks with Jasmine, so this is an option.

Now I just need to find some resources on what makes a good React unit test :D I mean I can write a bunch, but chances are that they don't add much value.

@brandonros
Copy link

Give yourself some credit mate. Just seeing how to import/mock/stub stuff will be a huge help. It'll really take this repo "to the next level" in my eyes. One stop shop. :)

@kay-is
Copy link
Owner Author

kay-is commented Jul 4, 2018

<!DOCTYPE html>
 
<script src="https://unpkg.com/[email protected]/umd/react.development.js"></script>
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>

<script src="https://unpkg.com/[email protected]/umd/react-test-renderer-shallow.development.js"></script>
<script src="https://unpkg.com/expect@%3C21/umd/expect.min.js"></script>

<script src="https://unpkg.com/[email protected]/mocha.js"></script>

<link href="https://unpkg.com/[email protected]/mocha.css" rel="stylesheet" />

<script type="text/babel">
mocha.setup("bdd");

const MyComponent = () => (
  <div>
    <span className="heading">Title</span>
  </div>
);

describe("Component", () => {
  it("Should render", () => {
    const renderer = new ReactShallowRenderer();
    renderer.render(<MyComponent />);
    const result = renderer.getRenderOutput();

    expect(result.type).toBe("div");
    expect(result.props.children).toEqual(<span className="heading">Title</span>);
  })
});

    mocha.checkLeaks();
    mocha.run();
</script>

<div id="mocha"></div>

Got a first draft done with Mocha.

kay-is added a commit that referenced this issue Jul 5, 2018
@mdsaleemj
Copy link

Hey @kay-is , why are you not using ES6 code, since it has become defacto for learning react .Even facebook recommends that . i know ES6 syntax will add learning complexity for beginners. just curious to know .

@kay-is
Copy link
Owner Author

kay-is commented Jul 13, 2018

@mdsaleemj I thought about this, but I'm not sure it would much value. I mostly talk about how React concepts relate to basic JavaScript constructs, which are already part of ES5 (objects, functions etc).

But yeah, I guess this is something to consider in a year or two, when basically all JS devs know about >ES5 constructs like classes etc.

@justinformentin
Copy link

justinformentin commented Aug 4, 2018

I think it would be worth it. In my eyes, two very important issues arise when using ES5.

First off, most instructions online nowadays are ES6. Documentation, tutorials, you name it. Second, when getting a job, having ES6 in your projects is miles better than ES5. Will it matter all the time? Absolutely not. But when it does matter, it's important. I've seen people get passed on jobs because "Why are they still writing ES5?"

Related to the fact that most things about React are in ES6 now, teaching someone something in ES5 is just delaying the inevitable. It's an improvement, and if you're a newbie and starting from the ground up, learning best practices and the tricks for ES6 are easiest right now, instead of learning ES5, and then having to go and figure out ES6 as well.

@brandonros
Copy link

@justinformentin I kind of disagree. I cling to ES5 because there is a lot less magic. I find myself having to paste ES6 blobs of code into the Babel REPL to see what it transpiles to. It's kind of refreshing that this repo shows React in an alternative fashion that has less tricks.

But, you aren't wrong that the world has left ES5 behind and is ES6 focused. I feel my opinion is an unpopular one.

@kay-is
Copy link
Owner Author

kay-is commented Aug 4, 2018

My assumption is: If you know ES6 then you know ES5, but not the other way around.

So writing for ES6 would exclude people, but writing for ES5 wouldn't.

sejas added a commit to reactspain/react-from-zero that referenced this issue Oct 11, 2018
10 Ejemplo de App, la numeración del título está mal, pero la corrijo yo ;)
Muchas gracias !
@babysophia1960
Copy link

Fffimage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants
@mdsaleemj @kay-is @brandonros @justinformentin @babysophia1960 and others