Giter Site home page Giter Site logo

crash.sandbox's Introduction

crash.sandbox

nvm -v
npm -v
node -v
npm install -g yarn
 npm install create-react-app -g

react-with-ts

App.tsx

create-react-app --template typescript react-with-ts
cd react-with-ts && yarn start
  1. interface:useState<IState['brands']>([])
  2. React.FC
  3. Converting .jsx to .tsx: --Stackoverflow

react-usecontext

  1. creating multiple nested components

    parent -> child1 -> child2 -> ... -> child5

  2. child5 would apply the value of hook useContext as to render.

react-memo

what is React.memo

eng:https://devdocs.io/react/react-api#reactmemo

zh-cn:https://zh-hans.reactjs.org/docs/react-api.html#reactmemo

  1. create a index.js file, then append a child called Swatch

  2. index.js is a React component,

  • it has states: count, color
  • two buttons can control its states and Re-Render App
  • Swatch receive props includes color
  1. Swatch without memo:
SWATCH HAS SAME PROPS: click color button 5 times ReRender App && Re-Render Swatch
SWATCH HAS Different PROPS: click color button 5 times ReRender App && Re-Render Swatch
  1. Swatch wrapped in memo:
 const T = React.memo(Swatch)
 return <T color={color}></T>
SWATCH HAS SAME PROPS: click count button 5 times ReRender App Only
SWATCH HAS Different PROPS: click color button 5 times ReRender App && Re-Render Swatch

crash.sandbox's People

Contributors

buuoltwo avatar

Watchers

 avatar

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.