Skip to content

Instantly share code, notes, and snippets.

@Suzangithub
Suzangithub / React: Pass an Array as Props
Created October 13, 2018 08:16
React: Pass an Array as Props
const List= (props) => {
{ /* change code below this line */ }
return <p>{props.tasks.join(", ")}</p>
{ /* change code above this line */ }
};
class ToDo extends React.Component {
constructor(props) {
super(props);
}
@Suzangithub
Suzangithub / React: Write a React Component from Scratch
Created October 12, 2018 15:23
React: Write a React Component from Scratch
// change code below this line
class MyComponent extends React.Component {
render() {
return (
<h1>My First React Component!
</h1>
)
}
};
ReactDOM.render(<MyComponent />,document.getElementById('challenge-node'));
@Suzangithub
Suzangithub / React: Compose React Components
Created October 12, 2018 14:48
React: Compose React Components
class Fruits extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<div>
<h2>Fruits:</h2>
{ /* change code below this line */ }
<NonCitrus />
@Suzangithub
Suzangithub / React: Use React to Render Nested Components
Created October 12, 2018 14:45
React: Use React to Render Nested Components
const TypesOfFruit = () => {
return (
<div>
<h2>Fruits:</h2>
<ul>
<li>Apples</li>
<li>Blueberries</li>
<li>Strawberries</li>
<li>Bananas</li>
</ul>
@Suzangithub
Suzangithub / React: Create a Component with Composition
Created October 12, 2018 10:17
React: Create a Component with Composition
const ChildComponent = () => {
return (
<div>
<p>I am the child</p>
</div>
);
};
class ParentComponent extends React.Component {
constructor(props) {
@Suzangithub
Suzangithub / React: Create a Complex JSX Element
Created October 10, 2018 08:45
React: Create a Complex JSX Element
// write your code here
const JSX = <div>
<h1>Heading.</h1>
<p>Paragraph</p>
<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
@Suzangithub
Suzangithub / Sass: Extend One Set of CSS Styles to Another Element
Created October 10, 2018 08:09
Sass: Extend One Set of CSS Styles to Another Element
<style type='text/sass'>
h3{
text-align: center;
}
.info{
width: 200px;
border: 1px solid black;
margin: 0 auto;
}
.info-important{
@Suzangithub
Suzangithub / Sass: Apply a Style Until a Condition is Met with @while
Created October 10, 2018 08:04
Sass: Apply a Style Until a Condition is Met with @while
<style type='text/sass'>
$x: 1;
@while $x < 11 {
.text-#{$x} { font-size: #{5*$x}px;}
$x: $x + 1;
}
</style>
@Suzangithub
Suzangithub / Sass: Use @each to Map Over Items in a List
Created October 10, 2018 07:51
Sass: Use @each to Map Over Items in a List
<style type='text/sass'>
$colors: (color1: blue, color2: black, color3: red);
@each $key, $color in $colors {
.#{$color}-text {color: $color;}
}
.blue-bg {
background-color: blue;
}
@Suzangithub
Suzangithub / Sass: Use @for to Create a Sass Loop
Created October 10, 2018 07:47
Sass: Use @for to Create a Sass Loop
<style type='text/sass'>
@for $j from 1 to 6 {
.text-#{$j} { font-size: 10px*$j; }
}
</style>