Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does SS stand for in a React Component declaration?

I don't see anything in the docs specifically about SS, I know P=props, and S=state but SS?

edit

Sorry, I was referencing this from a React+TypeScript project, namely @types/react. I have added the typescript tag.

https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/index.d.ts#L395

like image 538
RJ7 Avatar asked Jul 16 '19 14:07

RJ7


1 Answers

It's used in the return value of getSnapshotBeforeUpdate so I'm betting it stands for SnapShot.

Runs before React applies the result of render to the document, and returns an object to be given to componentDidUpdate. Useful for saving things such as scroll position before render causes changes to it.

And the docs in that file for componentDidUpdate show it accepts a third argument called snapshot that says:

The snapshot is only present if getSnapshotBeforeUpdate is present and returns non-null.

So, SS is the user defined type of the snapshot returned by your custom implementation of getSnapshotBeforeUpdate, which gets passed to componentDidUpdate so you can preserve some application specific details from the last render.

like image 175
Alex Wayne Avatar answered Nov 16 '22 01:11

Alex Wayne